Part Number Hot Search : 
MF514200 AS5306A SMA70 B1202 05S07 20M63 TA58L05 GMBT2411
Product Description
Full Text Search
 

To Download TS80C32X2-LIB Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  features ? high performance, low power 32-bit atmel ? avr ? microcontroller ? compact single-cycle risc instructio n set including dsp instruction set ? read-modify-write in structions and atomic bit manipulation ? performing up to 1.39 dmips / mhz ? up to 83 dmips running at 60 mhz from flash ? up to 46 dmips running at 30 mhz from flash ? memory protection unit ? multi-hierarchy bus system ? high-performance data transfers on separate buses for increased performance ? 7 peripheral dma channels improves speed for peripheral communication ? internal high-speed flash ? 512k bytes, 256k bytes, 128k bytes, 64k bytes versions ? single cycle access up to 30 mhz ? prefetch buffer optimizing instruction execution at maximum speed ? 4ms page programming time and 8ms full-chip erase time ? 100,000 write cycles, 15-year data retention capability ? flash security locks and user defined configuration area ? internal high-speed sram, single-cycle access at full speed ? 96k bytes (512kb flash), 32k bytes (256kb and 128kb flash), 16k bytes (64kb flash) ? interrupt controller ? autovectored low latency interrupt service with prog rammable priority ? system functions ? power and clock manager including inte rnal rc clock and one 32khz oscillator ? two multipurpose oscillators and two phase-lock-loop (pll) allowing independant cpu frequency from usb frequency ? watchdog timer, real-time clock timer ? universal serial bus (usb) ? device 2.0 and embedded host low speed and full speed ? flexible end-point configuration and management with dedicated dma channels ? on-chip transceivers including pull-ups ? usb wake up from sleep functionality ? one three-channel 16-b it timer/counter (tc) ? three external clock inputs, pwm, capture and various counting capabilities ? one 7-channel 20-bit pulse width modulation controller (pwm) ? three universal synchronous/asynchronous receiver/transmitters (usart) ? independant baudrate generator, support for spi, irda and iso7816 interfaces ? support for hardware handshaking, rs485 interfaces and modem line ? one master/slave serial peripheral in terfaces (spi) with chip select signals ? one synchronous serial protocol controller ? supports i 2 s and generic frame-based protocols ? one master/slave two-wire in terface (twi), 400kbit/s i 2 c-compatible ? one 8-channel 10-bit analog-to-digital converter, 384ks/s ? 16-bit stereo audio bitstream dac ? sample rate up to 50 khz ? qtouch ? library support ? capacitive touch buttons, sliders, and wheels ? qtouch and qmatrix acquisition 32059l?01/2012 32-bit atmel avr microcontroller at32uc3b0512 at32uc3b0256 at32uc3b0128 at32uc3b064 at32uc3b1512 at32uc3b1256 at32uc3b1128 at32uc3b164
2 32059l?avr32?01/2012 at32uc3b ? on-chip debug system (jtag interface) ? nexus class 2+, runtime control, non-intrusive data and program trace ? 64-pin tqfp/qfn (44 gpio pins), 48-pin tqfp/qfn (28 gpio pins) ? 5v input tolerant i/os, including 4 high-drive pins ? single 3.3v power supply or dual 1.8v-3.3v power supply
3 32059l?avr32?01/2012 at32uc3b 1. description the at32uc3b is a complete system-on-chip microcontroller based on the avr32 uc risc processor running at frequencies up to 60 mhz. avr32 uc is a high-performance 32-bit risc microprocessor core, designed for cost-sensitive embedded applications, with particular empha- sis on low power consumption, high code density and high performance. the processor implements a memory protection un it (mpu) and a fast and flexible interrupt con- troller for supporting modern operating systems and re al-time operating systems. higher computation capability is achieved using a rich set of dsp instructions. the at32uc3b incorporates on-chip flash and sram memories for secure and fast access. the peripheral direct memory access controller enables data transfers between peripherals and memories without processor involvement. pdca drastically reduces processing overhead when transferring continuous and large data streams between modules within the mcu. the power manager improves design flexibility and security: the on-chip brown-out detector monitors the power supply, the cpu runs from t he on-chip rc oscillator or from one of external oscillator sources, a real-time clock and its associated timer keeps track of the time. the timer/counter includes three identical 16- bit timer/counter channels. each channel can be independently programmed to perform frequency me asurement, event counting, interval mea- surement, pulse generation, delay timing and pulse width modulation. the pwm modules provides seven independent channels with many configuration options including polarity, edge alignment and waveform non overlap control. one pwm channel can trigger adc conversions for more accurate close loop control implementations. the at32uc3b also features many communica tion interfaces for communication intensive applications. in addition to standard serial inte rfaces like usart, spi or twi, other interfaces like flexible synchronous serial controller and usb are available. the usart supports different communication modes, like spi mode. the synchronous serial controller provides easy access to serial communication protocols and audio standards like i 2 s, uart or spi. the full-speed usb 2.0 device interface suppor ts several usb classes at the same time thanks to the rich end-point configuration. the embedded host interface allows device like a usb flash disk or a usb printer to be directly connected to the processor. atmel offers the qtouch library for embedding ca pacitive touch buttons, sliders, and wheels functionality into avr microcontrollers. the patented charge-transfer signal acquisition offers robust sensing and included fully debounced report ing of touch keys and includes adjacent key suppression ? (aks ? ) technology for unambiguous detection of key events. the easy-to-use qtouch suite toolchain allows you to explore, de velop, and debug your own touch applications. at32uc3b integrates a class 2+ nexus 2.0 on-chip debug (ocd) system, with non-intrusive real-time trace, full-speed read/write memory access in addition to basic runtime control. the nanotrace interface enables trace feature for jtag-based debuggers.
4 32059l?avr32?01/2012 at32uc3b 2. overview 2.1 blockdiagram figure 2-1. block diagram timer/counter interrupt controller real time counter peripheral dma controller hsb-pb bridge b hsb-pb bridge a s mm m s s m external interrupt controller high speed bus matrix general purpose ios general purpose ios pa pb a[2..0] b[2..0] clk[2..0] extint[7..0] kps[7..0] nmi gclk[3..0] xin32 xout32 xin0 xout0 p a p b reset_n 32 khz osc 115 khz rcosc osc0 pll0 serial peripheral interface two-wire interface pdc pdc miso, mosi npcs[3..0] scl sda usart1 pdc rxd txd clk rts, cts dsr, dtr, dcd, ri usart0 usart2 pdc rxd txd clk rts, cts synchronous serial controller pdc tx_clock, tx_frame_sync rx_data tx_data rx_clock, rx_frame_sync analog to digital converter pdc ad[7..0] advref watchdog timer xin1 xout1 osc1 pll1 sck jtag interface mcko mdo[5..0] mseo[1..0] evti_n tck tdo tdi tms power manager reset controller sleep controller clock controller clock generator configuration registers bus pb pb hsb hsb s flash controller m s usb interface dma id vbof vbus d- d+ evto_n avr32 uc cpu nexus class 2+ ocd instr interface data interface memory interface fast gpio 16/32/96 kb sram memory protection unit local bus interface audio bitstream dac pdc data[1..0] datan[1..0] pulse width modulation controller pwm[6..0] 64/128/ 256/512 kb flash
5 32059l?avr32?01/2012 at32uc3b 3. configuration summary the table below lists all at32uc3b memory and package configurations: table 3-1. configuration summary feature at32uc3b0512 at32uc3b0256/128/64 at32uc3b1512 at32uc3b1256/128/64 flash 512 kb 256/128/64 kb 512 kb 256/128/64 kb sram 96kb 32/32/16kb 96kb 32/16/16kb gpio 44 28 external interrupts 8 6 twi 1 usart 3 peripheral dma channels 7 spi 1 full speed usb mini-host + device device ssc 1 0 audio bitstream dac 1 0 1 0 timer/counter channels 3 pwm channels 7 watchdog timer 1 real-time clock timer 1 power manager 1 oscillators pll 80-240 mhz (pll0/pll1) crystal oscillators 0.4-20 mhz (osc0) crystal oscillator 32 khz (osc32k) rc oscillator 115 khz (rcsys) crystal oscillators 0.4-20 mhz (osc1) 10-bit adc number of channels 86 jtag 1 max frequency 60 mhz package tqfp64, qfn64 tqfp48, qfn48
6 32059l?avr32?01/2012 at32uc3b 4. package and pinout 4.1 package the device pins are multiplexed with peripheral functions as described in the peripheral multi- plexing on i/o line section. figure 4-1. tqfp64 / qfn64 pinout gnd 1 tck 2 pa00 3 pa01 4 pa02 5 pb00 6 pb01 7 vddcore 8 pa03 9 pa04 10 pa05 11 pa06 12 pa07 13 pa08 14 pa30 15 pa31 16 gndana 17 advref 18 vddana 19 vddout 20 vddin 21 vddcore 22 gnd 23 pb02 24 pb03 25 pb04 26 pb05 27 pa09 28 pa10 29 pa11 30 pa12 31 vddio 32 vddio 48 pa23 47 pa22 46 pa21 45 pa20 44 pb07 43 pa29 42 pa28 41 pa19 40 pa18 39 pb06 38 pa17 37 pa16 36 pa15 35 pa14 34 pa13 33 gnd 49 dp 50 dm 51 vbus 52 vddpll 53 pb08 54 pb09 55 vddcore 56 pb10 57 pb11 58 pa24 59 pa25 60 pa26 61 pa27 62 reset_n 63 vddio 64
7 32059l?avr32?01/2012 at32uc3b figure 4-2. tqfp48 / qfn48 pinout note: the exposed pad is not connected to anything internally, but should be soldered to ground to increase board level reliability. 4.2 peripheral multiplexing on i/o lines 4.2.1 multiplexed signals each gpio line can be assigned to one of 4 peripheral functions; a, b, c or d (d is only avail- able for uc3bx512 parts). the following table define how the i/o lines on the peripherals a, b,c or d are multiplexed by the gpio. gnd 1 tck 2 pa00 3 pa01 4 pa02 5 vddcore 6 pa03 7 pa04 8 pa05 9 pa06 10 pa07 11 pa08 12 gndana 13 advref 14 vddana 15 vddout 16 vddin 17 vddcore 18 gnd 19 pa09 20 pa10 21 pa11 22 pa12 23 vddio 24 vddio 36 pa23 35 pa22 34 pa21 33 pa20 32 pa19 31 pa18 30 pa17 29 pa16 28 pa15 27 pa14 26 pa13 25 gnd 37 dp 38 dm 39 vbus 40 vddpll 41 vddcore 42 pa24 43 pa25 44 pa26 45 pa27 46 reset_n 47 vddio 48 table 4-1. gpio controller func tion multiplexing 48-pin 64-pin pin gpio pin function a function b function c function d (only for uc3bx512) 3 3 pa00 gpio 0 4 4 pa01 gpio 1 5 5 pa02 gpio 2 7 9 pa03 gpio 3 adc - ad[0] pm - gclk[0] usbb - usb_id abdac - data[0] 8 10 pa04 gpio 4 adc - ad[1] pm - gclk[1] usbb - usb_vbof abdac - datan[0] 9 11 pa05 gpio 5 eic - extint[0] adc - ad[2] usart1 - dcd abdac - data[1]
8 32059l?avr32?01/2012 at32uc3b 10 12 pa06 gpio 6 eic - extint[1] adc - ad[3] usart1 - dsr abdac - datan[1] 11 13 pa07 gpio 7 pwm - pwm[0] adc - ad[4] usart1 - dtr ssc - rx_frame_sync 12 14 pa08 gpio 8 pwm - pwm[1] adc - ad[5] usart1 - ri ssc - rx_clock 20 28 pa09 gpio 9 twi - scl spi0 - npcs[2] usart1 - cts 21 29 pa10 gpio 10 twi - sda spi0 - npcs[3] usart1 - rts 22 30 pa11 gpio 11 usart0 - rts tc - a2 pwm - pwm[0] ssc - rx_data 23 31 pa12 gpio 12 usart0 - cts tc - b2 pwm - pwm[1] usart1 - txd 25 33 pa13 gpio 13 eic - nmi pwm - pwm[2] usart0 - clk ssc - rx_clock 26 34 pa14 gpio 14 spi0 - mosi pwm - pwm[3] eic - extint[2] pm - gclk[2] 27 35 pa15 gpio 15 spi0 - sck pwm - pwm[4] usart2 - clk 28 36 pa16 gpio 16 spi0 - npcs[0] tc - clk1 pwm - pwm[4] 29 37 pa17 gpio 17 spi0 - npcs[1] tc - clk2 spi0 - sck usart1 - rxd 30 39 pa18 gpio 18 usart0 - rxd pwm - pwm[5] spi0 - miso ssc - rx_frame_sync 31 40 pa19 gpio 19 usart0 - txd pwm - pwm[6] spi0 - mosi ssc - tx_clock 32 44 pa20 gpio 20 usart1 - clk tc - clk0 usart2 - rxd ssc - tx_data 33 45 pa21 gpio 21 pwm - pwm[2] tc - a1 usart2 - txd ssc - tx_frame_sync 34 46 pa22 gpio 22 pwm - pwm[6] tc - b1 adc - trigger abdac - data[0] 35 47 pa23 gpio 23 usart1 - txd spi0 - npcs[1] eic - extint[3] pwm - pwm[0] 43 59 pa24 gpio 24 usart1 - rxd spi0 - npcs[0] eic - extint[4] pwm - pwm[1] 44 60 pa25 gpio 25 spi0 - miso pwm - pwm[3] eic - extint[5] 45 61 pa26 gpio 26 usbb - usb_id usart2 - txd tc - a0 abdac - data[1] 46 62 pa27 gpio 27 usbb - usb_vbof usart2 - rxd tc - b0 abdac - datan[1] 41 pa28 gpio 28 usart0 - clk pwm - pwm[4] spi0 - miso abdac - datan[0] 42 pa29 gpio 29 tc - clk0 tc - clk1 spi0 - mosi 15 pa30 gpio 30 adc - ad[6] eic - scan[0] pm - gclk[2] 16 pa31 gpio 31 adc - ad[7] eic - scan[1] pwm - pwm[6] 6 pb00 gpio 32 tc - a0 eic - scan[2] usart2 - cts 7 pb01 gpio 33 tc - b0 eic - scan[3] usart2 - rts 24 pb02 gpio 34 eic - extint[6] tc - a1 usart1 - txd 25 pb03 gpio 35 eic - extint[7] tc - b1 usart1 - rxd 26 pb04 gpio 36 usart1 - cts spi0 - npcs[3] tc - clk2 27 pb05 gpio 37 usart1 - rts spi0 - npcs[2] pwm - pwm[5] 38 pb06 gpio 38 ssc - rx_clock usart1 - dcd eic - scan[4] abdac - data[0] 43 pb07 gpio 39 ssc - rx_data usart1 - dsr eic - scan[5] abdac - datan[0] 54 pb08 gpio 40 ssc - rx_frame_sync usart1 - dtr eic - scan[6] abdac - data[1] table 4-1. gpio controller func tion multiplexing
9 32059l?avr32?01/2012 at32uc3b 4.2.2 jtag port connections if the jtag is enabled, the jtag will take control over a number of pins, irre spective of the i/o controller configuration. 4.2.3 nexus ocd aux port connections if the ocd trace system is enabled, the trace system will take control over a number of pins, irre- spectively of the pio configuration. two different ocd trace pi n mappings are possible, depending on the configuratio n of the ocd axs register. for details, see the avr32 uc tech- nical reference manual . 4.2.4 oscillator pinout the oscillators are not mapped to the normal a, b or c functions and their muxings are con- trolled by registers in the power manager (pm). please refer to the power manager chapter for more information about this. 55 pb09 gpio 41 ssc - tx_clock usart1 - ri eic - scan[7] abdac - datan[1] 57 pb10 gpio 42 ssc - tx_data tc - a2 usart0 - rxd 58 pb11 gpio 43 ssc - tx_frame_sync tc - b2 usart0 - txd table 4-1. gpio controller func tion multiplexing table 4-2. jtag pinout 64qfp/qfn 48qfp/qfn pin name jtag pin 22tcktck 33pa00tdi 44pa01tdo 55pa02tms table 4-3. nexus ocd aux port connections pin axs=0 axs=1 evti_n pb05 pa14 mdo[5] pb04 pa08 mdo[4] pb03 pa07 mdo[3] pb02 pa06 mdo[2] pb01 pa05 mdo[1] pb00 pa04 mdo[0] pa31 pa03 evto_n pa15 pa15 mcko pa30 pa13 mseo[1] pb06 pa09 mseo[0] pb07 pa10
10 32059l?avr32?01/2012 at32uc3b 4.3 high drive current gpio ones of gpios can be used to drive twice curr ent than other gpio capability (see electrical characteristics section). 5. signals description the following table gives details on the signal name classified by peripheral. table 4-4. oscillator pinout qfp48 pin qfp64 pin pad oscillator pin 30 39 pa18 xin0 41 pa28 xin1 22 30 pa11 xin32 31 40 pa19 xout0 42 pa29 xout1 23 31 pa12 xout32 table 4-5. high drive current gpio gpio name pa20 pa21 pa22 pa23 table 5-1. signal description list signal name function type active level comments power vddpll pll power supply power input 1.65v to 1.95 v vddcore core power supply power input 1.65v to 1.95 v vddio i/o power supply power input 3.0v to 3.6v vddana analog power supply power input 3.0v to 3.6v vddin voltage regulator input supply power input 3.0v to 3.6v
11 32059l?avr32?01/2012 at32uc3b vddout voltage regulator output power output 1.65v to 1.95 v gndana analog ground ground gnd ground ground clocks, oscillators, and pll?s xin0, xin1, xin32 crystal 0, 1, 32 input analog xout0, xout1, xout32 crystal 0, 1, 32 output analog jtag tck test clock input tdi test data in input tdo test data out output tms test mode select input auxiliary port - aux mcko trace data output clock output mdo0 - mdo5 trace data output output mseo0 - mseo1 trace frame control output evti_n event in output low evto_n event out output low power manager - pm gclk0 - gclk2 generic clock pins output reset_n reset pin input low external interrupt controller - eic extint0 - extint7 external interrupt pins input kps0 - kps7 keypad scan pins output nmi non-maskable interrupt pin input low general purpose i/o pin- gpioa, gpiob pa0 - pa31 parallel i/o controller gpioa i/o pb0 - pb11 parallel i/o controller gpiob i/o table 5-1. signal description list (continued) signal name function type active level comments
12 32059l?avr32?01/2012 at32uc3b serial peripheral interface - spi0 miso master in slave out i/o mosi master out slave in i/o npcs0 - npcs3 spi peripheral chip select i/o low sck clock output synchronous serial controller - ssc rx_clock ssc receive clock i/o rx_data ssc receive data input rx_frame_sync ssc receive frame sync i/o tx_clock ssc transmit clock i/o tx_data ssc transmit data output tx_frame_sync ssc transmit frame sync i/o timer/counter - timer a0 channel 0 line a i/o a1 channel 1 line a i/o a2 channel 2 line a i/o b0 channel 0 line b i/o b1 channel 1 line b i/o b2 channel 2 line b i/o clk0 channel 0 external clock input input clk1 channel 1 external clock input input clk2 channel 2 external clock input input two-wire interface - twi scl serial clock i/o sda serial data i/o universal synchronous asynchronous receiver transmitter - usart0, usart1, usart2 clk clock i/o cts clear to send input table 5-1. signal description list (continued) signal name function type active level comments
13 32059l?avr32?01/2012 at32uc3b 5.1 jtag pins tms and tdi pins have pull-up resistors. tdo pin is an output, driven at up to vddio, and has no pull-up resistor. these 3 pins can be used as gp io-pins. at reset stat e, these pins are in gpio mode. tck pin cannot be used as gpio pin. jtag interface is enabled when tck pin is tied low. dcd data carrier detect only usart1 dsr data set ready only usart1 dtr data terminal ready only usart1 ri ring indicator only usart1 rts request to send output rxd receive data input txd transmit data output analog to digital converter - adc ad0 - ad7 analog input pins analog input advref analog positive reference voltage input analog input 2.6 to 3.6v audio bitstream dac - abdac data0 - data1 d/a data out output datan0 - datan1 d/a data inverted out output pulse width modulator - pwm pwm0 - pwm6 pwm output pins output universal serial bus device - usbb ddm usb device port data - analog ddp usb device port data + analog vbus usb vbus monitor and embedded host negociation analog input usbid id pin of the usb bus input usb_vbof usb vbus on/off: bus power control port output table 5-1. signal description list (continued) signal name function type active level comments
14 32059l?avr32?01/2012 at32uc3b 5.2 reset_n pin the reset_n pin is a schmitt input and integrates a permanent pull-up resistor to vddio. as the product integrates a power-on reset cell, th e reset_n pin can be le ft unconnected in case no reset from the system needs to be applied to the product. 5.3 twi pins when these pins are used for twi, the pins are open-drain outputs with slew-rate limitation and inputs with inputs with spike-filter ing. when used as gpio-pins or used for other peripherals, the pins have the same charac teristics as gpio pins. 5.4 gpio pins all the i/o lines integrate a pull-up resistor . programming of this pull-up resistor is performed independently for each i/o line through the gpio controllers. after reset, i/o lines default as inputs with pull-up resistors disabled, except when indicated otherwise in the column ?reset value? of the gpio controller user interface table. 5.5 high drive pins the four pins pa20, pa21, pa22, pa23 have high drive output capabilities. 5.6 power considerations 5.6.1 power supplies the at32uc3b has several types of power supply pins: ? vddio: powers i/o lines. voltage is 3.3v nominal. ? vddana: powers the adc vo ltage is 3.3v nominal. ? vddin: input voltage for the voltage regulator. voltage is 3.3v nominal. ? vddcore: powers the core, me mories, and periph erals. voltage is 1.8v nominal. ? vddpll: powers the pll. voltage is 1.8v nominal. the ground pins gnd are common to vddcore, vddio and vddpll. the ground pin for vddana is gndana. refer to electrical ch aracteristics section for power cons umption on the various supply pins. the main requirement for power supplies connection is to respect a star topology for all electrical connection.
15 32059l?avr32?01/2012 at32uc3b figure 5-1. power supply 5.6.2 voltage regulator 5.6.2.1 single power supply the at32uc3b embeds a voltage regulator that converts from 3.3v to 1.8v. the regulator takes its input voltage from vddin, and supplies the output voltage on vddout that should be exter- nally connected to the 1.8v domains. adequate input supply decoupling is mandatory for vddin in order to improve startup stability and reduce source voltage drop. two input decoupl ing capacitors must be placed close to the chip. adequate output supply decoupling is mandator y for vddout to reduce ripple and avoid oscil- lations. the best way to achiev e this is to use two capacitor s in parallel between vddout and gnd as close to the chip as possible figure 5-2. supply decoupling 3.3v vddana vddio vddin vddcore vddout vddpll advref 3.3v 1.8 v vddana vddio vddin vddcore vddout vddpll advref single power supply dual power supply 1.8v regulator 1.8v regulator 3.3v 1.8v vddin vddout 1.8v regulator c in1 c out1 c out2 c in2
16 32059l?avr32?01/2012 at32uc3b refer to section 28.3 on page 610 for decoupling capacitors values and regulator characteristics. for decoupling recommendations for vddio, vd dana, vddcore and vd dpll, please refer to the schematic checklist. 5.6.2.2 dual power supply in case of dual power supply, vddin and vddout should be connected to ground to prevent from leakage current. to avoid over consumption during the power up sequence, vd dio and vddcore voltage dif- ference needs to stay in the range given figure 5-3 . figure 5-3. vddio versus vddcore during power up sequence 5.6.3 analog-to-digital co nverter (adc) reference. the adc reference (advref) must be provi ded from an external source. two decoupling capacitors must be used to insure proper decoupling. figure 5-4. advref decoupling refer to section 28.4 on page 610 for decoupling capacitors values and electrical characteristics. in case adc is not used, the advref pin s hould be connected to gnd to avoid extra consumption. extra consumption on vddcore vddcore (v) extra consumption on vddio vddio (v) 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2 0 0.5 1.5 1 2 2.5 3 3.5 4 advref c c vref1 vref2 3.3v
17 32059l?avr32?01/2012 at32uc3b 6. processor and architecture rev: 1.0.0.0 this chapter gives an overview of the avr32uc cpu. avr32uc is an implementation of the avr32 architecture. a summary of the progr amming model, instruction set, and mpu is pre- sented. for further details, see the avr32 architecture manual and the avr32uc technical reference manual . 6.1 features ? 32-bit load/store avr32a risc architecture ? 15 general-purpose 32-bit registers ? 32-bit stack pointer, program counter and link register reside in register file ? fully orthogonal instruction set ? privileged and unprivileged modes enabling efficient and secure operating systems ? innovative instruction set together with variabl e instruction length ensuring industry leading code density ? dsp extention with saturating arithmetic, an d a wide variety of multiply instructions ? 3-stage pipeline allows one instructio n per clock cycle for most instructions ? byte, halfword, word and double word memory access ? multiple interrupt priority levels ? mpu allows for operating systems with memory protection 6.2 avr32 architecture avr32 is a high-performance 32-bit risc microprocessor architecture, designed for cost-sensi- tive embedded applications, with particular emph asis on low power consumption and high code density. in addition, the instruction set architec ture has been tuned to al low a variety of micro- architectures, enabling the avr32 to be implemented as low-, mid-, or high-performance processors. avr32 extends the avr family into the world of 32- and 64-bit applications. through a quantitative approach, a large set of industry recognized benchmarks has been com- piled and analyzed to achieve the best code density in its class. in addition to lowering the memory requirements, a compact code size also contributes to the core?s low power characteris- tics. the processor supports byte and halfword data types without penalty in code size and performance. memory load and store operations are provided for byte, halfword, word, and double word data with automatic sign- or zero extension of halfw ord and byte data. the c-compiler is closely linked to the architecture and is able to expl oit code optimization features, both for size and speed. in order to reduce code size to a minimum, so me instructions have multiple addressing modes. as an example, instructions with immediates often have a compact format with a smaller imme- diate, and an extended format with a larger immediate. in this way, the compiler is able to use the format giving the smallest code size. another feature of the instruction set is that fr equently used instructions, like add, have a com- pact format with two operands as well as an extended format with three operands. the larger format increases performance, allowing an addition and a data move in the same instruction in a single cycle. load and store instructions have several different formats in order to reduce code size and speed up execution.
18 32059l?avr32?01/2012 at32uc3b the register file is organized as sixteen 32-bi t registers and includes the program counter, the link register, and the stack pointer. in addition, register r12 is designed to hold return values from function calls and is used im plicitly by some instructions. 6.3 the avr32uc cpu the avr32uc cpu targets low- and mediu m-performance applications, and provides an advanced ocd system, no caches, and a memory protection unit (mpu). java acceleration hardware is not implemented. avr32uc provides three memory interfaces, one high speed bus master for instruction fetch, one high speed bus master for data access, an d one high speed bus sl ave interface allowing other bus masters to access data rams internal to t he cpu. keeping data ra ms internal to the cpu allows fast access to the rams, reduces latency, and guarantees deterministic timing. also, power consumption is reduced by not needing a full high speed bus access for memory accesses. a dedicated data ram interface is prov ided for communicating with the internal data rams. a local bus interface is provided for connecting the cpu to device-specific high-speed systems, such as floating-point units and fast gpio ports. this local bus has to be enabled by writing the locen bit in the cpucr system register. the loca l bus is able to trans fer data between the cpu and the local bus slave in a single clock cycle. the local bus has a dedicated memory range allocated to it, and data transfers are per formed using regular load and store instructions. details on which devices that are mapped into the local bus space is given in the memories chapter of this data sheet. figure 6-1 on page 19 displays the contents of avr32uc.
19 32059l?avr32?01/2012 at32uc3b figure 6-1. overview of the avr32uc cpu 6.3.1 pipeline overview avr32uc has three pipeline stages, instruction fetc h (if), instruction deco de (id), and instruc- tion execute (ex). the ex stage is split into three parallel subsections, one ar ithmetic/logic (alu) section, one multiply (mul) sect ion, and one load/store (ls) section. instructions are issued and complete in order. certain operations require several clock cycles to complete, and in this case, the instruction resides in the id and ex stages for the required num- ber of clock cycles. since there is only three pipeline stages, no inte rnal data forwarding is required, and no data dependencies can arise in the pipeline. figure 6-2 on page 20 shows an overview of the avr32uc pipeline stages. avr32uc cpu pipeline instruction memory controller high speed bus master mpu high speed bus high speed bus ocd system ocd interface interrupt controller interface high speed bus slave high speed bus data ram interface high speed bus master power/ reset control reset interface cpu local bus master cpu local bus data memory controller
20 32059l?avr32?01/2012 at32uc3b figure 6-2. the avr32uc pipeline 6.3.2 avr32a microarchitecture compliance avr32uc implements an avr32a microarchitect ure. the avr32a microarchitecture is tar- geted at cost-sensitive, lower-end applicati ons like smaller microcontrollers. this microarchitecture does not provide dedicated hard ware registers for shadow ing of register file registers in interrupt contexts. additionally, it does not provide hardware registers for the return address registers and return status registers. instead, all this in formation is stored on the system stack. this saves chip area at the expense of slower interrupt handling. upon interrupt initiation, registers r8-r12 are automatically pushed to th e system stack. these registers are pushed regardless of the priority leve l of the pending interrupt. the return address and status register are also automatically pushed to stack. the interrupt handler can therefore use r8-r12 freely. upon interrupt completion, th e old r8-r12 registers and status register are restored, and execution continues at the return address stored popped from stack. the stack is also used to store the status register and return address for exceptions and scall . executing the rete or rets instruction at the completion of an exception or system call will pop this status register and continue ex ecution at the popped return address. 6.3.3 java support avr32uc does not provide java hardware acceleration. 6.3.4 memory protection the mpu allows the user to check all memory accesses for privilege violations. if an access is attempted to an illegal memory address, the access is aborted and an exception is taken. the mpu in avr32uc is specified in t he avr32uc technical reference manual. 6.3.5 unaligned reference handling avr32uc does not support unaligned accesses, except for doubleword accesses. avr32uc is able to perform word-aligned st.d and ld.d . any other unaligned memory access will cause an address exception. doubleword -sized accesses with word-align ed pointers will automatically be performed as two word-sized accesses. if id alu mul regfile write prefetch unit decode unit alu unit multiply unit load-store unit ls regfile read
21 32059l?avr32?01/2012 at32uc3b the following table shows the instructions wit h support for unaligned addresses. all other instructions requir e aligned addresses. 6.3.6 unimplemented instructions the following instructions are unimplemented in avr32uc, and will cause an unimplemented instruction exception if executed: ? all simd instructions ? all coprocessor instructions if no coprocessors are present ? retj, incjosp, popjc, pushjc ? tlbr, tlbs, tlbw ? cache 6.3.7 cpu and architecture revision three major revisions of the avr32uc cpu currently exist. the architecture revision field in the config0 system register identifies which architecture revision is implemented in a specific device. avr32uc cpu revision 3 is fully backward-compatible with revisions 1 and 2, ie. code compiled for revision 1 or 2 is binary-compatible with revision 3 cpus. table 6-1. instructions with una ligned reference support instruction supported alignment ld.d word st.d word
22 32059l?avr32?01/2012 at32uc3b 6.4 programming model 6.4.1 register file configuration the avr32uc register file is shown below. figure 6-3. the avr32uc register file 6.4.2 status register configuration the status register (sr) is split into tw o halfwords, one upper and one lower, see figure 6-4 on page 22 and figure 6-5 on page 23 . the lower word contains the c, z, n, v, and q condition code flags and the r, t, and l bits, while the upper halfword contains information about the mode and state the processor executes in. refer to the avr32 architecture manual for details. figure 6-4. the status register high halfword application bit 0 supervisor bit 31 pc sr int0pc fintpc int1pc smpc r7 r5 r6 r4 r3 r1 r2 r0 bit 0 bit 31 pc sr r12 int0pc fintpc int1pc smpc r7 r5 r6 r4 r11 r9 r10 r8 r3 r1 r2 r0 int0 sp_app sp_sys r12 r11 r9 r10 r8 exception nmi int1 int2 int3 lr lr bit 0 bit 31 pc sr r12 int0pc fintpc int1pc smpc r7 r5 r6 r4 r11 r9 r10 r8 r3 r1 r2 r0 sp_sys lr bit 0 bit 31 pc sr r12 int0pc fintpc int1pc smpc r7 r5 r6 r4 r11 r9 r10 r8 r3 r1 r2 r0 sp_sys lr bit 0 bit 31 pc sr r12 int0pc fintpc int1pc smpc r7 r5 r6 r4 r11 r9 r10 r8 r3 r1 r2 r0 sp_sys lr bit 0 bit 31 pc sr r12 int0pc fintpc int1pc smpc r7 r5 r6 r4 r11 r9 r10 r8 r3 r1 r2 r0 sp_sys lr bit 0 bit 31 pc sr r12 int0pc fintpc int1pc smpc r7 r5 r6 r4 r11 r9 r10 r8 r3 r1 r2 r0 sp_sys lr bit 0 bit 31 pc sr r12 int0pc fintpc int1pc smpc r7 r5 r6 r4 r11 r9 r10 r8 r3 r1 r2 r0 sp_sys lr secure bit 0 bit 31 pc sr r12 int0pc fintpc int1pc smpc r7 r5 r6 r4 r11 r9 r10 r8 r3 r1 r2 r0 sp_sec lr ss_status ss_adrf ss_adrr ss_adr0 ss_adr1 ss_sp_sys ss_sp_app ss_rar ss_rsr bit 31 0 0 0 bit 16 interrupt level 0 mask interrupt level 1 mask interrupt level 3 mask interrupt level 2 mask 1 0 0 0 0 1 1 0 0 0 0 0 0 fe i0m gm m1 - d m0 em i2m dm - m2 lc 1 initial value bit name i1m mode bit 0 mode bit 1 - mode bit 2 reserved debug state - i3m reserved exception mask global interrupt mask debug state mask -
23 32059l?avr32?01/2012 at32uc3b figure 6-5. the status register low halfword 6.4.3 processor states 6.4.3.1 normal risc state the avr32 processor supports several diff erent execution contexts as shown in table 6-2 on page 23 . mode changes can be made under software control, or can be caused by external interrupts or exception processing. a mode can be interrupted by a higher priority mode, but never by one with lower priority. ne sted exceptions can be supported with a minimal software overhead. when running an operating system on the avr32, user processes will typically execute in the application mode. the programs executed in this mode are restricted from executing certain instructions. furthermore, most system register s together with the upper halfword of the status register cannot be accessed. protected memory ar eas are also not available. all other operating modes are privileged and are collectively called system modes. they have full access to all priv- ileged and unprivileged resources. after a reset, the processo r will be in supervisor mode. 6.4.3.2 debug state the avr32 can be set in a debug state, which allows implementation of software monitor rou- tines that can read out and alter system inform ation for use during application development. this implies that all system and application regist ers, including the status registers and program counters, are accessible in debug state. th e privileged instructions are also available. bit 15 bit 0 reserved carry zero sign 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - - - - t - bit name initial value 0 0 l q v n z c - overflow saturation - - - lock reserved scratch table 6-2. overview of execution modes, thei r priorities and privilege levels. priority mode securi ty description 1 non maskable interrupt privileged non maskable high priority interrupt mode 2 exception privileged execute exceptions 3 interrupt 3 privileged general purpose interrupt mode 4 interrupt 2 privileged general purpose interrupt mode 5 interrupt 1 privileged general purpose interrupt mode 6 interrupt 0 privileged general purpose interrupt mode n/a supervisor privileged runs supervisor calls n/a application unprivileged normal program execution mode
24 32059l?avr32?01/2012 at32uc3b all interrupt levels are by default disabled when debug state is entered, but they can individually be switched on by the monitor routine by clearing the respective mask bit in the status register. debug state can be entered as described in the avr32uc technical reference manual . debug state is exited by the retd instruction. 6.4.4 system registers the system registers are placed outside of the virtual memory space, and are only accessible using the privileged mfsr and mtsr instructions. the table below lis ts the system registers speci- fied in the avr32 architecture, some of which are unused in avr32uc. the programmer is responsible for maintaining correct sequen cing of any instructions following a mtsr instruction. for detail on the system registers, refer to the avr32uc technical reference manual . table 6-3. system registers reg # address name function 0 0 sr status register 1 4 evba exception vector base address 2 8 acba application call base address 3 12 cpucr cpu control register 4 16 ecr exception cause register 5 20 rsr_sup unused in avr32uc 6 24 rsr_int0 unused in avr32uc 7 28 rsr_int1 unused in avr32uc 8 32 rsr_int2 unused in avr32uc 9 36 rsr_int3 unused in avr32uc 10 40 rsr_ex unused in avr32uc 11 44 rsr_nmi unused in avr32uc 12 48 rsr_dbg return status register for debug mode 13 52 rar_sup unused in avr32uc 14 56 rar_int0 unused in avr32uc 15 60 rar_int1 unused in avr32uc 16 64 rar_int2 unused in avr32uc 17 68 rar_int3 unused in avr32uc 18 72 rar_ex unused in avr32uc 19 76 rar_nmi unused in avr32uc 20 80 rar_dbg return address register for debug mode 21 84 jecr unused in avr32uc 22 88 josp unused in avr32uc 23 92 java_lv0 unused in avr32uc 24 96 java_lv1 unused in avr32uc 25 100 java_lv2 unused in avr32uc
25 32059l?avr32?01/2012 at32uc3b 26 104 java_lv3 unused in avr32uc 27 108 java_lv4 unused in avr32uc 28 112 java_lv5 unused in avr32uc 29 116 java_lv6 unused in avr32uc 30 120 java_lv7 unused in avr32uc 31 124 jtba unused in avr32uc 32 128 jbcr unused in avr32uc 33-63 132-252 reserved reserved for future use 64 256 config0 configuration register 0 65 260 config1 configuration register 1 66 264 count cycle counter register 67 268 compare compare register 68 272 tlbehi unused in avr32uc 69 276 tlbelo unused in avr32uc 70 280 ptbr unused in avr32uc 71 284 tlbear unused in avr32uc 72 288 mmucr unused in avr32uc 73 292 tlbarlo unused in avr32uc 74 296 tlbarhi unused in avr32uc 75 300 pccnt unused in avr32uc 76 304 pcnt0 unused in avr32uc 77 308 pcnt1 unused in avr32uc 78 312 pccr unused in avr32uc 79 316 bear bus error address register 80 320 mpuar0 mpu address register region 0 81 324 mpuar1 mpu address register region 1 82 328 mpuar2 mpu address register region 2 83 332 mpuar3 mpu address register region 3 84 336 mpuar4 mpu address register region 4 85 340 mpuar5 mpu address register region 5 86 344 mpuar6 mpu address register region 6 87 348 mpuar7 mpu address register region 7 88 352 mpupsr0 mpu privilege se lect register region 0 89 356 mpupsr1 mpu privilege se lect register region 1 90 360 mpupsr2 mpu privilege se lect register region 2 91 364 mpupsr3 mpu privilege se lect register region 3 table 6-3. system registers (continued) reg # address name function
26 32059l?avr32?01/2012 at32uc3b 6.5 exceptions and interrupts avr32uc incorporates a powerful exception hand ling scheme. the different exception sources, like illegal op-code and external interrupt requests, have different priority levels, ensuring a well- defined behavior when multiple exceptions ar e received simultaneously. additionally, pending exceptions of a higher priority class may preempt handling of ongoing exceptions of a lower pri- ority class. when an event occurs, the execution of the instru ction stream is halted, and execution control is passed to an event handler at an address specified in table 6-4 on page 29 . most of the han- dlers are placed sequentially in the code space starting at the address specified by evba, with four bytes between each handler. this gives am ple space for a jump instruction to be placed there, jumping to the event rout ine itself. a few critical handle rs have larger spacing between them, allowing the entire event routine to be placed directly at the address specified by the evba-relative offset generated by hardware. all external interrupt sources have autovectored interrupt service routine (isr) addresses. this allo ws the interrupt controller to directly specify the isr address as an address relative to evba. the autovector offset has 14 address bits, giv- ing an offset of maximum 16384 bytes. the target address of the event handler is calculated as (evba | event_handler_offset), not (evba + even t_handler_offset), so evba and exception code segments must be set up appropriately. th e same mechanisms are used to service all dif- ferent types of events, including external in terrupt requests, yielding a uniform event handling scheme. an interrupt controller does the priority handlin g of the external interrupts and provides the autovector offset to the cpu. 6.5.1 system stack issues event handling in avr32uc uses the system stack pointed to by the system stack pointer, sp_sys, for pushing and popping r8 -r12, lr, status register, and return ad dress. since event code may be timing-critical, sp_sys should point to memory addresses in the iram section, since the timing of accesses to this memory section is both fast and deterministic. 92 368 mpupsr4 mpu privilege se lect register region 4 93 372 mpupsr5 mpu privilege se lect register region 5 94 376 mpupsr6 mpu privilege se lect register region 6 95 380 mpupsr7 mpu privilege se lect register region 7 96 384 mpucra unused in this version of avr32uc 97 388 mpucrb unused in this version of avr32uc 98 392 mpubra unused in this version of avr32uc 99 396 mpubrb unused in this version of avr32uc 100 400 mpuapra mpu access permission register a 101 404 mpuaprb mpu access permission register b 102 408 mpucr mpu control register 103-191 448-764 reserved reserved for future use 192-255 768-1020 impl implementation defined table 6-3. system registers (continued) reg # address name function
27 32059l?avr32?01/2012 at32uc3b the user must also make sure that the system st ack is large enough so that any event is able to push the required registers to stack. if the syst em stack is full, and an event occurs, the system will enter an undefined state. 6.5.2 exceptions and interrupt requests when an event other than scall or debug request is received by the core, the following actions are performed atomically: 1. the pending event will not be accepted if it is masked. the i3m, i2m, i1m, i0m, em, and gm bits in the status register are used to mask different events. not all events can be masked. a few critical events (nmi, unre coverable exception, tlb multiple hit, and bus error) can not be masked. when an ev ent is accepted, hardware automatically sets the mask bits corresponding to all sources with equal or lower priority. this inhibits acceptance of other events of the same or lo wer priority, except fo r the critical events listed above. software may choose to clear some or all of these bits after saving the necessary state if other priority schemes are desired. it is the event source?s respons- ability to ensure that their events are le ft pending until accepted by the cpu. 2. when a request is accepted, the status re gister and program counter of the current context is stored to the system stack. if the event is an int0, int1, int2, or int3, reg- isters r8-r12 and lr are also automatically stored to stack. storing the status register ensures that the core is returned to the previous execution mode when the current event handling is completed. when ex ceptions occur, both the em and gm bits are set, and the application may manually en able nested exceptions if desired by clear- ing the appropriate bit. each exception handler has a dedicated handler address, and this address uniquely identifies the exception source. 3. the mode bits are set to reflect the priority of the accepted event, and the correct regis- ter file bank is selected. the address of th e event handler, as shown in table 6-4, is loaded into the program counter. the execution of the event handler routine then continues from the effective address calculated. the rete instruction signals the end of the event. wh en encountered, the re turn status register and return address register are popped from th e system stack and restored to the status reg- ister and program counter. if the rete instruction returns from int0, int1, int2, or int3, registers r8-r12 and lr are also popped from t he system stack. the restored status register contains information allowing the core to resume operation in the previous execution mode. this concludes the event handling. 6.5.3 supervisor calls the avr32 instruction set provides a supervisor mode call instruction. the scall instruction is designed so that privileged routines can be ca lled from any context. this facilitates sharing of code between different execution modes. the scall mechanism is designed so that a minimal execution cycle overhead is experienced when performing supervisor routine calls from time- critical event handlers. the scall instruction behaves differently depending on which mode it is called from. the behav- iour is detailed in the instruction se t reference. in order to allow the scall routine to return to the correct context, a return from supervisor call instruction, rets , is implemented. in the avr32uc cpu, scall and rets uses the system stack to store the re turn address and t he status register. 6.5.4 debug requests the avr32 architecture defines a dedicated deb ug mode. when a debug request is received by the core, debug mode is entered. entry into de bug mode can be masked by the dm bit in the
28 32059l?avr32?01/2012 at32uc3b status register. upon entry into debug mode, hardware sets the sr[d] bit and jumps to the debug exception handler. by default, debug mode executes in the exception context, but with dedicated return address register and return status register. thes e dedicated registers remove the need for storing this data to the system stack, t hereby improving debuggability. the mode bits in the status regist er can freely be manipulated in d ebug mode, to observe registers in all contexts, while retaining full privileges. debug mode is exited by executing the retd instruction. this return s to the previous context. 6.5.5 entry points for events several different event handler entry points exists. in avr32uc, the reset address is 0x8000_0000. this places the reset add ress in the boot flash memory area. tlb miss exceptions and scall have a dedicated space relative to evba where their event han- dler can be placed. this speeds up execution by removing the need for a jump instruction placed at the program address jumped to by the event hardware. all other exceptions have a dedicated event routine entry point locat ed relative to evba. the handler routine address identifies the exception source directly. avr32uc uses the itlb and dtlb protection exc eptions to signal a mp u protection violation. itlb and dtlb miss exceptions are used to sig nal that an access address did not map to any of the entries in the mpu. tlb multiple hit exception indicates that an access address did map to multiple tlb entries, signalling an error. all external interrupt r equests have entry point s located at an offset relative to evba. this autovector offset is specified by an external interrupt controller. the programmer must make sure that none of the autovector offsets interfere with the placem ent of other co de. the autovec- tor offset has 14 address bits, giving an offset of maximum 16384 bytes. special considerations should be made when loading evba with a po inter. due to security con- siderations, the event handlers should be locate d in non-writeable flash memory, or optionally in a privileged memory protection region if an mpu is present. if several events occur on the same instruction, th ey are handled in a prioritized way. the priority ordering is presented in table 6-4. if events occu r on several instructions at different locations in the pipeline, the events on the oldest instruction are always handled before any events on any younger instruction, even if the younger instructi on has events of higher priority than the oldest instruction. an instruction b is yo unger than an instruction a if it was sent down the pipeline later than a. the addresses and priority of simultaneous event s are shown in table 6-4. some of the excep- tions are unused in avr32uc since it has no mmu, coprocessor interface, or floating-point unit.
29 32059l?avr32?01/2012 at32uc3b table 6-4. priority and handler addresses for events priority handler address name event source stored return address 1 0x8000_0000 reset external input undefined 2 provided by ocd system ocd stop cpu ocd system first non-compl eted instruction 3 evba+0x00 unrecoverable exception int ernal pc of offending instruction 4 evba+0x04 tlb multiple hit mpu 5 evba+0x08 bus error data fetch data bu s first non-complet ed instruction 6 evba+0x0c bus error instruct ion fetch data bus first non -completed instruction 7 evba+0x10 nmi external input first non-completed instruction 8 autovectored interrupt 3 request external input first non-completed instruction 9 autovectored interrupt 2 request external input first non-completed instruction 10 autovectored interrupt 1 request external input first non-completed instruction 11 autovectored interrupt 0 request external input first non-completed instruction 12 evba+0x14 instruction address cpu pc of offending instruction 13 evba+0x50 itlb miss mpu 14 evba+0x18 itlb protection mpu pc of offending instruction 15 evba+0x1c breakpoint ocd system firs t non-completed instruction 16 evba+0x20 illegal opcode instructio n pc of offending instruction 17 evba+0x24 unimplemented instruction instr uction pc of offending instruction 18 evba+0x28 privilege violation instruc tion pc of offending instruction 19 evba+0x2c floating-point unused 20 evba+0x30 coprocessor absent instruct ion pc of offending instruction 21 evba+0x100 supervisor call instru ction pc(supervisor call) +2 22 evba+0x34 data address (read) cp u pc of offending instruction 23 evba+0x38 data address (write) cpu pc of offending instruction 24 evba+0x60 dtlb miss (read) mpu 25 evba+0x70 dtlb miss (write) mpu 26 evba+0x3c dtlb protection (read) mpu pc of offending instruction 27 evba+0x40 dtlb protection (write) m pu pc of offending instruction 28 evba+0x44 dtlb modified unused
30 32059l?avr32?01/2012 at32uc3b 6.6 module configuration all at32uc3b parts do not implement the same cpu and architecture revision. table 6-5. cpu and architecture revision part name architecture revision at32uc3bx512 2 at32uc3bx256 1 at32uc3bx128 1 at32uc3bx64 1
31 32059l?avr32?01/2012 at32uc3b 7. memories 7.1 embedded memories ? internal high-speed flash ? 512kbytes (at32uc3b0512, at32uc3b1512) ? 256 kbytes (at32uc3b0256, at32uc3b1256) ? 128 kbytes (at32uc3b0128, at32uc3b1128) ? 64 kbytes (at32uc3b064, at32uc3b164) ? - 0 wait state access at up to 30 mhz in worst case conditions ? - 1 wait state access at up to 60 mhz in worst case conditions ? - pipelined flash architecture, allowing burst reads from sequential flash locations, hiding penalty of 1 wait state access ? - 100 000 write cycles, 15-year data retention capability ? - 4 ms page programming time, 8 ms chip erase time ? - sector lock capabilities, boot loader protection, security bit ? - 32 fuses, erased during chip erase ? - user page for data to be preserved during chip erase ? internal high-speed sram, single-cycle access at full speed ? 96kbytes ((at32uc3b0512, at32uc3b1512) ? 32kbytes (at32uc3b0256, at32uc3b0128, at32uc3b1256 and at32uc3b1128) ? 16kbytes (at32uc3b064 and at32uc3b164) 7.2 physical memory map the system bus is implemented as a bus matrix . all system bus addresses are fixed, and they are never remapped in any way, not even in boot. note that avr32 uc cpu uses unsegmented translation, as described in the avr32uc technical architecture manual. the 32-bit physical address space is mapped as follows: table 7-1. at32uc3b physical memory map device embedded sram embedded flash usb data hsb-pb bridge a hsb-pb bridge b start address 0x0000_0000 0x8000_0000 0xd000_0000 0xffff_0000 0xfffe_0000 size at32uc3b0512 at32uc3b1512 96 kbytes 512 kbytes 64 kbytes 64 kbytes 64 kbytes at32uc3b0256 at32uc3b1256 32 kbytes 256 kbytes 64 kbytes 64 kbytes 64 kbytes at32uc3b0128 at32uc3b1128 32 kbytes 128 kbytes 64 kbytes 64 kbytes 64 kbytes at32uc3b064 at32uc3b164 16 kbytes 64 kbytes 64 kbytes 64 kbytes 64 kbytes
32 32059l?avr32?01/2012 at32uc3b 7.3 peripheral address map table 7-2. peripheral address mapping address peripheral name 0xfffe0000 usb usb 2.0 interface - usb 0xfffe1000 hmatrix hsb matrix - hmatrix 0xfffe1400 hflashc flash cont roller - hflashc 0xffff0000 pdca peripheral dma controller - pdca 0xffff0800 intc interrupt controller - intc 0xffff0c00 pm power manager - pm 0xffff0d00 rtc real time counter - rtc 0xffff0d30 wdt watchdog timer - wdt 0xffff0d80 eim external interrupt controller - eim 0xffff1000 gpio general purpose input/output controller - gpio 0xffff1400 usart0 universal synchronous/asynchronous receiver/transmitter - usart0 0xffff1800 usart1 universal synchronous/asynchronous receiver/transmitter - usart1 0xffff1c00 usart2 universal synchronous/asynchronous receiver/transmitter - usart2 0xffff2400 spi0 serial peripher al interface - spi0 0xffff2c00 twi two-wire interface - twi 0xffff3000 pwm pulse width modulation controller - pwm 0xffff3400 ssc synchronous serial controller - ssc 0xffff3800 tc timer/counter - tc
33 32059l?avr32?01/2012 at32uc3b 7.4 cpu local bus mapping some of the registers in the gpio module are mapped onto the cpu local bus, in addition to being mapped on the peripheral bus. these registers can therefore be reached both by accesses on the peripheral bus, and by accesses on the local bus. mapping these registers on the local bus allows cy cle-deterministic toggli ng of gpio pins since the cpu and gpio are the only mo dules connected to this bus. also, since the local bus runs at cpu speed, one write or read operation can be pe rformed per clock cycle to the local bus- mapped gpio registers. the following gpio registers are mapped on the local bus: 0xffff3c00 adc analog to digital converter - adc 0xffff4000 abdac audio bitstream dac - abdac table 7-2. peripheral address mapping table 7-3. local bus mapped gpio registers port register mode local bus address access 0 output driver enable register (oder) write 0x4000_0040 write-only set 0x4000_0044 write-only clear 0x4000_0048 write-only toggle 0x4000_004c write-only output value register (ovr) write 0x4000_0050 write-only set 0x4000_0054 write-only clear 0x4000_0058 write-only toggle 0x4000_005c write-only pin value register (pvr) - 0x4000_0060 read-only 1 output driver enable register (oder) write 0x4000_0140 write-only set 0x4000_0144 write-only clear 0x4000_0148 write-only toggle 0x4000_014c write-only output value register (ovr) write 0x4000_0150 write-only set 0x4000_0154 write-only clear 0x4000_0158 write-only toggle 0x4000_015c write-only pin value register (pvr) - 0x4000_0160 read-only
34 32059l?avr32?01/2012 at32uc3b 8. boot sequence this chapter summarizes the boot sequence of the at32uc3b. the behaviour after power-up is controlled by the power manager . for specific details, refer to section power manager (pm). 8.1 starting of clocks after power-up, the device will be held in a reset state by the power-on reset circuitry, until the power has stabilized throughout the device. once the power has stabilized, the device will use the internal rc oscilla tor as clock source. on system start-up, the plls are disabled. all clocks to all modules are running. no clocks have a divided frequency, all parts of the system re cieves a clock with the same frequency as the internal rc oscillator. 8.2 fetching of initial instructions after reset has been released, the avr32 uc cpu starts fetching instructions from the reset address, which is 0x8000_0000. this address poin ts to the first address in the internal flash. the code read from the internal flash is free to configure the system to use for example the plls, to divide the frequency of the clock routed to some of the peripherals, and to gate the clocks to unused peripherals. when powering up the device, there may be a delay before the voltage has stabilized, depend- ing on the rise time of the supply used. the cpu can start executing code as soon as the supply is above the por threshold, and before the supply is stable. before switching to a high-speed clock source, the user should use the bod to make sure the vddcore is above the minimum level.
35 32059l?avr32?01/2012 at32uc3b 9. power manager (pm) rev: 2.3.0.2 9.1 features ? controls integrated oscillators and plls ? generates clocks and resets for digital logic ? supports 2 crystal oscillators 0.4-20 mhz ? supports 2 plls 80-240 mhz ? supports 32 khz ultra-low power oscillator ? integrated low-power rc oscillator ? on-the fly frequency change of cpu, hsb, pba, and pbb clocks ? sleep modes allow simple disabling of logic clocks, plls , and oscillators ? module-level clock gating through maskable peripheral clocks ? wake-up from internal or external interrupts ? generic clocks with wide frequency range provided ? automatic identification of reset sources ? controls brownout detector (bod), rc oscillator, and bandgap voltage reference through control and calibration registers 9.2 description the power manager (pm) controls the oscillators and plls, and generates the clocks and resets in the device. the pm cont rols two fast crystal oscillators , as well as two plls, which can multiply the clock from either oscillator to provide higher frequencies. additionally, a low-power 32 khz oscillator is used to generate the real-time counter clock for high accuracy real-time measurements. the pm also contains a low-power rc oscillator with fast start-up time, which can be used to clock the digital logic. the provided clocks are divided into synchr onous and generic clocks. the synchronous clocks are used to clock the main digital logic in the device, namely the cpu, and the modules and peripherals connected to the hsb, pba, and pbb buses. the generic clocks are asynchronous clocks, which can be tuned precisely within a wi de frequency range, which makes them suitable for peripherals that require specific frequencies, such as timers and communication modules. the pm also contains advanced power-saving feat ures, allowing the user to optimize the power consumption for an application. the synchronous clocks are divided into three clock domains, one for the cpu and hsb, one for modules on the pba bus, and one for modules on the pbb bus.the three clocks can run at different speeds, so the user can save power by running periph- erals at a relatively low clock, while maintaining a high cpu performance. additionally, the clocks can be independently changed on-the-fly, wit hout halting any periph erals. this enables the user to adjust the speed of the cpu and memo ries to the dynamic load of the application, without disturbing or re-configuring active peripherals. each module also has a separate clock, enabling t he user to switch off the clock for inactive modules, to save further pow er. additionally, clocks and os cillators can be automatically switched off during idle period s by using the sleep instruction on the cpu. the system will return to normal on occurrence of interrupts. the power manager also contains a reset contro ller, which collects all possible reset sources, generates hard and soft resets, and allows th e reset source to be identified by software.
36 32059l?avr32?01/2012 at32uc3b 9.3 block diagram figure 9-1. power manager block diagram sleep controller oscillator and pll control pll0 pll1 synchronous clock generator generic clock generator reset controller oscillator 0 oscillator 1 rc oscillator startup counter slow clock sleep instruction power-on detector other reset sources resets generic clocks synchronous clocks cpu, hsb, pba, pbb osc/pll control signals rcosc 32 khz oscillator 32 khz clock for rtc interrupts external reset pad calibration registers brown-out detector voltage regulator fuses
37 32059l?avr32?01/2012 at32uc3b 9.4 product dependencies 9.4.1 i/o lines the pm provides a number of generic clock out puts, which can be connected to output pins, multiplexed with gpio lines. the programmer must first program the gpio controller to assign these pins to their peripheral f unction. if the i/o pins of the pm are not used by the application, they can be used for other pur poses by the gpio controller. 9.4.2 interrupt the pm interrupt line is connected to one of the in ternal sources of the interrupt controller. using the pm interrupt requires the interrup t controller to be programmed first. 9.4.3 clock implementation in at32uc3b, the hsb shares the source clock with the cpu. this means that writing to the hsbdiv and hsbsel bits in cksel has no effect. these bits will always read the same as cpudiv and cpusel. 9.5 functional description 9.5.1 slow clock the slow clock is generated from an internal rc oscillator which is always running, except in static mode. the slow clock can be used for t he main clock in the device, as described in ?syn- chronous clocks? on page 39 . the slow clock is also used for the watchdog timer and measuring various delays in the power manager. the rc oscillator has a 3 cycles st artup time, and is always available when the cpu is running. the rc oscillator operates at approximately 115 khz, and can be calibrated to a narrow range by the rcosccal fuses. software can also c hange rc oscillator calibra tion through the use of the rccr register. please see the electric al characteristics section for details. rc oscillator can also be used as the rtc cl ock when crystal accura cy is not required. 9.5.2 oscillator 0 and 1 operation the two main oscillators are desi gned to be used with an external crystal and two biasing capac- itors, as shown in figure 9-2 . oscillator 0 can be used for the main clock in the device, as described in ?synchronous clocks? on page 39 . both oscillators can be used as source for the generic clocks, as described in ?generic clocks? on page 43 . the oscillators are disabled by default after re set. when the oscillators are disabled, the xin and xout pins can be used as gener al purpose i/os. when the oscilla tors are configured to use an external clock, the clock must be applied to t he xin pin while the xout pin can be used as a general purpose i/o. the oscillators can be enabled by writing to the oscnen bits in mcctrl. operation mode (external clock or crysta l) is chosen by writing to the mode field in oscctrln. oscillators are automatically switched off in certain sleep modes to reduce power consumption, as described in section 9.5.7 on page 42 . after a hard reset, or when wa king up from a sleep mode that di sabled the oscillators, the oscil- lators may need a certain amount of time to stabilize on the corr ect frequency. th is start-up time can be set in the oscctrln register.
38 32059l?avr32?01/2012 at32uc3b the pm masks the oscillator outputs during the start- up time, to ensure t hat no unstable clocks propagate to the digital logic. the oscnrdy bi ts in poscsr are automatically set and cleared according to the status of the oscillators. a zero to one transition on th ese bits can also be con- figured to generate an interrupt, as described in ?mode: oscillator mode? on page 57 . figure 9-2. oscillator connections 9.5.3 32 khz oscillator operation the 32 khz oscillator operates as described for oscilla tor 0 and 1 above. the 32 khz oscillator is used as source clock for the real-time counter. the oscillator is disabled by default, but can be enabled by writing osc32en in oscctrl32. the oscillator is an ultra-low po wer design and remains enabled in all sleep modes except static mode. while the 32 khz oscillator is disabled, the xin32 and xout32 pins are available as general purpose i/os. when the oscillator is configured to work with an external clock (mode field in oscctrl32 register), the external clock must be connected to xin32 while the xout32 pin can be used as a general purpose i/o. the startup time of the 32 khz oscillator can be set in the oscctrl32, after which osc32rdy in poscsr is set. an interrupt can be genera ted on a zero to one transition of osc32rdy. as a crystal oscillator usually requires a very long startup time (up to 1 second), the 32 khz oscillator will keep running across resets, except power-on-reset. 9.5.4 pll operation the device contains two plls, pll0 and pll1. these are disabled by default, but can be enabled to provide high frequency source clo cks for synchronous or generic clocks. the plls can take either oscillator 0 or 1 as reference clock. t he pll output is divided by a multiplication factor, and the pll compares the resulting clock to the reference clock. the pll will adjust its output frequency until the two compared clocks are equal, thus locking the output frequency to a multiple of the reference clock frequency. the voltage controlled oscillator inside the pll can generate fr equencies from 80 to 240 mhz. to make the pll output frequen cies under 80 mhz the otp[1] bitfield could be set. this will divide the output of the pll by two and bring the clock in range of the max frequency of the cpu. xin xout c 2 c 1
39 32059l?avr32?01/2012 at32uc3b when the pll is switched on, or when changing th e clock source or multiplication factor for the pll, the pll is unlocked and the output frequency is undefined. the pll clock for the digital logic is automatically masked when the pll is unlocked, to prevent connected digital logic from receiving a too high frequency and thus become unstable. figure 9-3. pll with control logic and filters 9.5.4.1 enabling the pll plln is enabled by writing the pllen bit in th e plln register. pllosc selects oscillator 0 or 1 as clock source. the pllmul and plldiv bitfields must be written with the multiplication and division factors, respectively, creating t he voltage controlled ocillator frequency f vco and the pll frequency f pll : f vco = (pllmul+1)/(plldiv) ? f osc if plldiv > 0. f vco = 2*(pllmul+1) ? f osc if plldiv = 0. if pllopt[1] field is set to 0: f pll = f vco. if pllopt[1] field is set to 1: f pll = f vco / 2 . the plln:pllopt field should be set to proper values according to the pll operating fre- quency. the pllopt field can also be set to divide the output frequency of the plls by 2. the lock signal for each pll is available as a lockn flag in poscsr. an interrupt can be gen- erated on a 0 to 1 transition of these bits. 9.5.5 synchronous clocks the slow clock (default), oscillato r 0, or pll0 provide the source for the main clock, which is the common root for the synchronous clocks for the cpu/hsb, pba, and pbb modules. the main clock is divided by an 8-bit prescaler, and ea ch of these four synchronous clocks can run from phase detector output divider 0 1 osc0 clock osc1 clock pllosc pllo pt pllm ul lock bit mask pll clock input divider plldiv 1/2 pllopt[1] 0 1 vco f vco f pll lock detector
40 32059l?avr32?01/2012 at32uc3b any tapping of this prescaler, or the undivided main clock, as long as f cpu f pba,b, . the synchro- nous clock source can be changed on-the fly, resp onding to varying load in the application. the clock domains can be shut down in sleep mode, as described in ?sleep modes? on page 42 . additionally, the clocks for each module in the four domains can be individually masked, to avoid power consumption in inactive modules. figure 9-4. synchronous clock generation 9.5.5.1 selecting pll or os cillator for the main clock the common main clock can be connected to the slow clock, oscillator 0, or pll0. by default, the main clock will be connected to the slow clo ck. the user can connect the main clock to oscil- lator 0 or pll0 by writing the mcsel bitfield in the main clock control register (mcctrl). this must only be done after that unit has been enabl ed, otherwise a deadlock will occur. care should also be taken that the new frequency of the synchronous clocks does not exceed the maximum frequency for each clock domain. 9.5.5.2 selecting synchron ous clock division ratio the main clock feeds an 8-bit prescaler, which can be used to generate the synchronous clocks. by default, the synchronous clocks run on the undivided main clock. the user can select a pres- caler division for the cpu cloc k by writing cksel:cpudiv to 1 and cpusel to the prescaling value, resulting in a cpu clock frequency: f cpu = f main / 2 (cpusel+1) mask prescaler osc0 clock pll0 clock mcsel 0 1 cpusel cpudiv main clock sleep controller cpumask cpu clocks hsb clocks pbaclocks pbb clocks sleep instruction slow clock
41 32059l?avr32?01/2012 at32uc3b similarly, the clock for the pba, and pbb can be divided by writin g their respective bitfields. to ensure correct operation, frequenci es must be selected so that f cpu f pba,b . also, frequencies must never exceed the specified maxi mum frequency for each clock domain. cksel can be written without hal ting or disabling peripheral m odules. writing cksel allows a new clock setting to be written to all synchronous clocks at the sa me time. it is possible to keep one or more clocks unchanged by writing the same value a before to the xxxdiv and xxxsel bit- fields. this way, it is possi ble to e.g. scale cpu and hsb speed according to the required performance, while keeping the pba and pbb frequency constant. for modules connected to the hsb bus, the pb clock frequency must be set to the same fre- quency than the cpu clock. 9.5.5.3 clock ready flag there is a slight delay from cksel is written and the new clock setting becomes effective. dur- ing this interval, the clock ready (c krdy) flag in isr will read as 0. if ier:ckrdy is written to 1, the power manager interrupt can be triggered wh en the new clock settin g is effective. cksel must not be re-written while ckrdy is 0, or the system may become unstable or hang. 9.5.6 peripheral clock masking by default, the clock for all modules are enabled, regardless of which modules are actually being used. it is possible to disable the clock for a module in the cpu, hsb, pba, or pbb clock domain by writing the correspondi ng bit in the clock mask regi ster (cpu/hsb/pba/pbb) to 0. when a module is not clocked, it will cease operation, and its re gisters cannot be read or written. the module can be re-enabled later by writing the corresponding mask bit to 1. a module may be connected to several clock domains, in which case it will have several mask bits. table 9-6 contains a list of implemented maskable clocks. 9.5.6.1 cautionary note note that clocks should only be switched off if it is certain that the module will not be used. switching off the clock for the internal ram will cause a pr oblem if the stack is mapped there. switching off the clock to the power manager (pm), which contains the mask registers, or the corresponding pbx bridge, will make it impossible to write the mask registers again. in this case, they can only be re-enabled by a system reset. 9.5.6.2 mask ready flag due to synchronization in the clock generator, there is a slight delay from a mask register is writ- ten until the new mask setting goes into effect. when clearing mask bits, this delay can usually be ignored. however, when setting mask bits, the registers in the corresponding module must not be written until the clock has actually be re-enabled. the status flag mskrdy in isr pro- vides the required mask status information. when wr iting either mask register with any value, this bit is cleared. the bit is set when the clocks have been enabled and disabled according to the new mask setting. optionally, the power ma nager interrupt can be enabled by writing the mskrdy bit in ier.
42 32059l?avr32?01/2012 at32uc3b 9.5.7 sleep modes in normal operation, all clock domains are acti ve, allowing software execution and peripheral operation. when the cpu is idle, it is possible to switch off the cpu clock and optionally other clock domains to save power. this is activate d by the sleep instruction, which takes the sleep mode index number as argument. 9.5.7.1 entering and exiting sleep modes the sleep instruction will halt the cpu and all modules belonging to t he stopped clock domains. the modules will be halted regardless of th e bit settings of the mask registers. oscillators and plls can also be switched off to save power. so me of these modules have a rel- atively long start-up time, and are only swit ched off when very low power consumption is required. the cpu and affected modules are restarted when the sleep mode is ex ited. this occurs when an interrupt triggers. note that even if an interr upt is enabled in sleep mode, it may not trigger if the source module is not clocked. 9.5.7.2 supported sleep modes the following sleep modes are supported. these are detailed in table 9-1 . ?idle: the cpu is stopped, the rest of the chip is operating. wake-up sources are any interrupt. ?frozen: the cpu and hsb modules are stopped, peripherals are operating. wake-up sources are any interrupts from pb modules. ?standby: all synchronous clocks are stopped, bu t oscillators and plls are running, allowing quick wake-up to normal mode. wake-up sources are rtc or external interrupt (eic), external reset or any asynchronous interrupts fr om pb modules. ?stop: as standby, but oscillat or 0 and 1, and the plls are stopped. 32 khz (if enabled) and rc oscillators and rtc/wdt will still operate. wa ke-up are the same as for standby mode. ?deepstop: all synchronous clocks, oscillator 0 and 1 and pll 0 and 1 are stopped. 32 khz oscillator can run if enabled. rc oscillator st ill operates. bandgap volt age reference and bod is turned off. wake-up sources are rtc, external interrupt in asynchronous mode, external reset or any asynchronous interrupts from pb modules. ?static: all oscillators, including 32 khz and rc oscillator are stopped. bandgap voltage refer- ence bod detector is turned off. wake-up sources are external interrupt (eic) in asynchronous mode only, external reset pin or any asynchronous interrupts from pb modules. table 9-1. sleep modes index sleep mode cpu hsb pba,b gclk osc0,1 pll0,1, systimer osc32 rcosc bod & bandgap voltage regulator 0 idle stop run run run run run on full power 1 frozen stop stop run run run run on full power 2 standby stop stop stop run run run on full power 3 stop stop stop stop stop run run on low power 4 deepstop stop stop stop stop run run off low power 5 static stop stop stop stop stop stop off low power
43 32059l?avr32?01/2012 at32uc3b the power level of the internal voltage regulator is also adjusted according to the sleep mode to reduce the internal regulator power consumption. 9.5.7.3 precautions when entering sleep mode modules communicating with external circuits should normally be disabled before entering a sleep mode that will stop the mo dule operation. this prevents erratic behavior when entering or exiting sleep mode. please refer to the re levant module documentation for recommended actions. communication between the synchronous clock do mains is disturbed when entering and exiting sleep modes. this means that bus transactions are not allowed between clock domains affected by the sleep mode. the system may hang if th e bus clocks are stopped in the middle of a bus transaction. the cpu is automatically stopped in a safe state to ensure that all cpu bus operations are com- plete when the sleep mode goes into effect. th us, when entering idle mode, no further action is necessary. when entering a sleep mode (except idle mode), all hsb masters must be stopped before entering the sleep mode. also, if there is a ch ance that any pb write operations are incomplete, the cpu should perform a read operation from any register on the pb bus before executing the sleep instruction. this will stall the cpu while waiting for any pend ing pb operations to complete. when entering a sleep mode deeper or equal to deepstop, the vbus asynchronous interrupt should be disabled (usbcon.vbuste = 0). 9.5.7.4 wake up the usb can be used to wake up the part from sleep modes through register awen of the power manager. 9.5.8 generic clocks timers, communication modules, and other modules connected to external circuitry may require specific clock frequencies to operate correctly . the power manager contains an implementation defined number of generic clocks that can prov ide a wide range of accurate clock frequencies. each generic clock module runs from either oscilla tor 0 or 1, or pll0 or 1. the selected source can optionally be divided by any even integer up to 512. each clock can be independently enabled and disabled, and is also automatically disabled along with peripheral clocks by the sleep controller.
44 32059l?avr32?01/2012 at32uc3b figure 9-5. generic clock generation 9.5.8.1 enabling a generic clock a generic clock is enabled by writi ng the cen bit in gcctrl to 1. each generic clock can use either oscillator 0 or 1 or p ll0 or 1 as source, as selected by the pllsel and oscsel bits. the source clock can optionally be divided by wr iting diven to 1 and the division factor to div, resulting in the output frequency: f gclk = f src / (2*(div+1)) 9.5.8.2 disabling a generic clock the generic clock can be disabled by writing cen to 0 or entering a sleep mode that disables the pb clocks. in either case, the generic clock will be switched off on the first falling edge after the disabling event, to ensu re that no glitches occur. if cen is written to 0, the bit will still read as 1 until the next falling edge occu rs, and the clock is actually sw itched off. when writing cen to 0, the other bits in gcctrl should not be changed un til cen reads as 0, to avoid glitches on the generic clock. when the clock is disabled, both the prescaler and output are reset. 9.5.8.3 changing clock frequency when changing generic clock frequency by writ ing gcctrl, the clock should be switched off by the procedure above, before being re-enabled with the new clock source or division setting. this prevents glitches du ring the transition. divider 0 1 osc0 clock pll0 clock pllsel oscsel osc1 clock pll1 clock generic clock div 0 1 diven mask cen sleep controller
45 32059l?avr32?01/2012 at32uc3b 9.5.8.4 generic clock implementation in at32uc3b, there are 5 generic clocks. these ar e allocated to different functions as shown in table 9-2 . 9.5.9 divided pb clocks the clock generator in the power manager pr ovides divided pba and pbb clocks for use by peripherals that require a prescaled pbx clock. this is described in the documentation for the relevant modules. the divided clocks are not directly maskable, but are stopped in sleep modes where the pbx clocks are stopped. 9.5.10 debug operation during a debug session, the user may need to halt the system to inspect memory and cpu reg- isters. the clocks normally keep running during this debug opera tion, but some peripherals may require the clocks to be stopped, e.g. to prev ent timer overflow, which would cause the program to fail. for this reason, peripherals on th e pba and pbb buses may use ?debug qualified? pbx clocks. this is described in the documentation for the relevant modules. the divided pbx clocks are always debug qualified clocks. debug qualified pb clocks are stopped duri ng debug operation. the debug system can option- ally keep these clocks r unning during the debug operation. this is described in the documentation for the on-chip debug system. 9.5.11 reset controller the reset controller collects the various reset sources in the system and generates hard and soft resets for the digital logic. the device contains a power-on detector, which keeps the system reset until power is stable. this eliminates the need for external reset circui try to guarantee stable operation when powering up the device. it is also possible to reset the device by asserting the reset_n pin. this pin has an internal pul- lup, and does not need to be dr iven externally when negated. table 9-4 lists these and other reset sources supported by the reset controller. table 9-2. generic clock allocation clock number function 0gclk0 pin 1gclk1 pin 2gclk2 pin 3 usbb 4abdac
46 32059l?avr32?01/2012 at32uc3b figure 9-6. reset controller block diagram in addition to the listed reset types, the jtag can keep parts of the device statically reset through the jtag reset register. s ee jtag documentation for details. table 9-3. reset description when a reset occurs, some parts of the chip are not necessarily reset, depending on the reset source. only the power on reset (por ) will force a reset of the whole chip. reset source description power-on reset supply voltage below the power-on reset detector threshold voltage external reset reset_n pin asserted brownout reset supply voltage below the brownout reset detector threshold voltage cpu error caused by an illegal cpu access to external memory while in supervisor mode watchdog timer see watchdog timer documentation. ocd see on-chip debug documentation jtag reset controller reset_n power-on detector ocd watchdog reset rc_rcause cpu, hsb, pba, pbb ocd, rtc/wdt clock generato brownout detector
47 32059l?avr32?01/2012 at32uc3b table 9-4 lists parts of the device that are reset, depending on the reset source. the cause of the last reset can be read from the rcause register. this register contains one bit for each reset source, and can be read during the boot sequence of an application to determine the proper action to be taken. 9.5.11.1 power-on detector the power-on detector monitors the vddcore supply pin and generates a reset when the device is powered on. the reset is active until the supply voltage from the linear regulator is above the power-on threshold leve l. the reset will be re -activated if the vo ltage drops below the power-on threshold level. see electrical characteristics for parametric details. 9.5.11.2 brown-out detector the brown-out detector (bod) monitors t he vddcore supply pin and compares the supply voltage to the brown-out detection level, as set in bod.level. the bod is disabled by default, but can be enabled either by software or by flas h fuses. the brown-out detector can either gen- erate an interrupt or a reset when the supply voltage is below the brown-out detection level. in any case, the bod output is available in bit poscr.bodet bit. note 1 : any change to the bod.level field of the bod register should be done with the bod deactivated to avoid spurious reset or interrupt. note 2 : if the bod level is set to a value hi gher than vddcore and enabled by fuses, the part will be in constant reset. in order to leave reset state, an external voltage higher than the bod level should be applied. thus, it is possible to disable bod. table 9-4. effect of the different reset events power-on reset external reset watchdog reset bod reset cpu error reset ocd reset cpu/hsb/pba/pbb (excluding power manager) yyyyyy 32khz oscillator ynnnnn rtc control register ynnnnn gplp registers ynnnnn watchdog control register y y n y y y voltage calibration register ynnnnn rc oscillator calibration registerynnnnn bod control register y y n n n n bandgap control register y y n n n n clock control registers yyyyyy osc0/osc1 and control registersyyyyyy pll0/pll1 and control registersyyyyyy ocd system and ocd registers y y n y y n
48 32059l?avr32?01/2012 at32uc3b see electrical characterist ics for parametric details. 9.5.11.3 external reset the external reset detector monitors the state of the reset_n pin. by default, a low level on this pin will generate a reset. 9.5.12 calibration registers the power manager controls the calibration of the rc oscillator, voltage regulator, bandgap voltage reference through several calibration registers. those calibration registers are loaded after a po wer on reset with default values stored in fac- tory-programmed flash fuses. although it is not reco mmended to override default factory settings, it is still possible to override these default values by writing to those register s. to prevent unexpected writes due to software bugs, write access to these registers is protected by a ?key?. first, a write to the register must be made with the field ?key? equal to 0x55 then a second write must be issued with the ?key? field equal to 0xaa
49 32059l?avr32?01/2012 at32uc3b 9.6 user interface table 9-5. pm register memory map offset register register name access reset 0x0000 main clock control register mcctrl read/write 0x00000000 0x0004 clock select register cksel read/write 0x00000000 0x0008 cpu mask register cpumask read/write 0x00000003 0x000c hsb mask register hsbmask read/write 0x0000007f 0x0010 pba mask register pbamask read/write 0x00007fff 0x0014 pbb mask register pbbmask read/write 0x0000003f 0x0020 pll0 control register pll0 read/write 0x00000000 0x0024 pll1 control register pll1 read/write 0x00000000 0x0028 oscillator 0 control register oscctrl0 read/write 0x00000000 0x002c oscillator 1 control register oscctrl1 read/write 0x00000000 0x0030 oscillator 32 control register oscctrl32 read/write 0x00010000 0x0040 interrupt enable register ier write-only 0x00000000 0x0044 interrupt disable regi ster idr write-only 0x00000000 0x0048 interrupt mask register imr read-only 0x00000000 0x004c interrupt status register isr read-only 0x00000000 0x0050 interrupt clear register icr write-only 0x00000000 0x0054 power and oscillators status register poscsr read/write 0x00000000 0x0060-0x070 generic clock control register gcctrl read/write 0x00000000 0x00c0 rc oscillator calibration r egister rccr read/write factory settings 0x00c4 bandgap calibration register bgcr read/write factory settings 0x00c8 linear regulator calibration r egister vregcr read/write factory settings 0x00d0 bod level register bod read/write bod fuses in flash 0x0140 reset cause register rcause read-only latest reset source 0x0144 asynchronous wake up enab le register awen read/write 0x00000000 0x0200 general purpose low-power register 0 gplp0 read/write 0x00000000 0x0204 general purpose low-power register 1 gplp1 read/write 0x00000000
50 32059l?avr32?01/2012 at32uc3b 9.6.1 main clock control register name: mcctrl access type: read/write offset: 0x000 reset value: 0x00000000 ? osc1en: oscillator 1 enable 0: oscillator 1 is disabled. 1: oscillator 1 is enabled. ? osc0en: oscillator 0 enable 0: oscillator 0 is disabled. 1: oscillator 0 is enabled. ? mcsel: main clock select 0: the slow clock is the source for the main clock. 1: oscillator 0 is the source for the main clock. 2: pll0 is the source for the main clock. 3: reserved. ? 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - osc1en osc0en mcsel
51 32059l?avr32?01/2012 at32uc3b 9.6.2 clock select register name: cksel access type: read/write offset: 0x004 reset value: 0x00000000 ? pbbdiv, pbbsel: pbb division and clock select pbbdiv = 0: pbb clock equals main clock. pbbdiv = 1: pbb clock equals main clock divided by 2 (pbbsel+1) . ? pbadiv, pbasel: pba division and clock select pbadiv = 0: pba clock equals main clock. pbadiv = 1: pba clock equals main clock divided by 2 (pbasel+1) . ? hsbdiv, hsbsel: hsb division and clock select for the at32uc3b , hsbdiv always equals cpudiv, and hsbsel always equals cpusel, as the hsb clock is always equal to the cpu clock. ? cpudiv, cpusel: cpu division and clock select cpudiv = 0: cpu clock equals main clock. cpudiv = 1: cpu clock equals main clock divided by 2 (cpusel+1) . note that if xxxdiv is written to 0, xxxsel shou ld also be written to 0 to ensure correct operation. also note that writing this register clears poscsr:ckrdy. the register must not be re-written until ckrdy goes high. 31 30 29 28 27 26 25 24 pbbdiv - - - - pbbsel 23 22 21 20 19 18 17 16 pbadiv - - - - pbasel 15 14 13 12 11 10 9 8 hsbdiv - - - - hsbsel 76543210 cpudiv - - - - cpusel
52 32059l?avr32?01/2012 at32uc3b 9.6.3 clock mask register name: cpu/hsb/pba/pbbmask access type: read/write offset: 0x008, 0x00c, 0x010, 0x014 reset value: - 31 30 29 28 27 26 25 24 mask[31:24] 23 22 21 20 19 18 17 16 mask[23:16] 15 14 13 12 11 10 9 8 mask[15:8] 76543210 mask[7:0]
53 32059l?avr32?01/2012 at32uc3b ? mask: clock mask if bit n is cleared, the clock for module n is stopped. if bit n is set, the clock for module n is enabled according to the cur rent power mode. the number of implemented bits in each mask regist er, as well as which module clock is controlled by each bit, is shown in table 9-6 . note: 1. this bit must be one if the user wishes to debug the device with a jtag debugger. table 9-6. maskable module clocks in at32uc3b. bit cpumask hsbmask pbamask pbbmask 0 - flashc intc hmatrix 1ocd (1) pba bridge gpio usbb 2 - pbb bridge pdca flashc 3 - usbb pm/rtc/eic - 4 - pdca adc - 5 - - spi - 6- - twi - 7 - - usart0 - 8 - - usart1 - 9 - - usart2 - 10 - - pwm - 11 - - ssc - 12 - - tc - 13 - - abdac - 14---- 15---- 16 systimer (compare/count registers clk) --- 31: 17 ----
54 32059l?avr32?01/2012 at32uc3b 9.6.4 pll control register name: pll0,1 access type: read/write offset: 0x020, 0x024 reset value: 0x00000000 ? pllcount: pll count specifies the number of slow clock cycles before isr:lockn will be set after plln ha s been written, or after plln has been automatically re-enabled after exiting a sleep mode. ? pllmul: pll multiply factor ? plldiv: pll division factor these fields determine the ratio of the ouput frequency of the internal vco of the pll (f vco ) to the source oscillator frequency: ? f vco = (pllmul+1)/(plldiv) * f osc if plldiv > 0. ? f vco = 2 * (pllmul+1) * f osc if plldiv = 0. if pllopt[1] bit is set to 0: f pll = f vco. if pllopt[1] bit is set to 1: f pll = f vco / 2 . note that the pllmul field cannot be equal to 0 or 1, or the behavior of the pll will be undefined. plldiv gives also the input frequency of the pll (f in ): if the plldiv field is set to 0: f in = f osc. if the plldiv field is greater than 0: f in = f osc / (2 * plldiv). ? pllopt: pll option select the operating range for the pll. pllopt[0]: select the vco frequency range. pllopt[1]: enable the extra output divider. pllopt[2]: disable the wide-bandwidth mode (wide-bandwidth mode allows a faster startup time and out-of-lock time). ? 31 30 29 28 27 26 25 24 - - pllcount 23 22 21 20 19 18 17 16 ---- pllmul 15 14 13 12 11 10 9 8 ---- plldiv 76543210 - - - pllopt pllosc pllen
55 32059l?avr32?01/2012 at32uc3b ? ? ? pllosc: pll oscillator select 0: oscillator 0 is the source for the pll. 1: oscillator 1 is the source for the pll. ? pllen: pll enable 0: pll is disabled. 1: pll is enabled. ? table 9-7. pllopt fields description in at32uc3b description pllopt[0]: vco frequency 0160mhz 56 32059l?avr32?01/2012 at32uc3b 9.6.5 oscillator 0/1 control register name : oscctrl0,1 access type: read/write offset: 0x028, 0x02c reset value: 0x00000000 ? startup: oscilla tor startup time select startup time for the oscillator. ? mode: oscillator mode choose between crystal, or external clock 0: external clock connected on xin, xout can be used as an i/o (no crystal). 1 to 3: reserved . 4: crystal is connected to xin/xout - osci llator is used with gain g0 ( xin from 0.4 mhz to 0.9 mhz ). 5: crystal is connected to xin/xout - osci llator is used with gain g1 ( xin from 0.9 mhz to 3.0 mhz ). 6: crystal is connected to xin/xout - osci llator is used with gain g2 ( xin from 3.0 mhz to 8.0 mhz ). 7: crystal is connected to xin/xout - osci llator is used with gain g3 ( xin from 8.0 mhz). 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ----- startup 76543210 ----- mode table 9-8. startup time for o scillators 0 and 1 startup number of rc oscillator clock cycle approximative equivalent time (rcosc = 115 khz) 00 0 1 64 560 us 2128 1.1ms 32048 18ms 44096 36ms 58192 71ms 6 16384 142 ms 7 reserved reserved
57 32059l?avr32?01/2012 at32uc3b 9.6.6 32 khz oscillator control register name: oscctrl32 access type: read/write offset: 0x030 reset value: 0x00010000 note: this register is only reset by power-on reset ? startup: oscillato r startup time select startup time for 32 khz oscillator. ? mode: oscillator mode choose between crystal, or external clock. 0: external clock connected on xin32, xout32 can be used as a i/o (no crystal). 1: crystal is connected to xin32/xout32. 2 to 7: reserved . ? osc32en: enable the 32 khz oscillator 0: 32 khz oscillator is disabled. 1: 32 khz oscillator is enabled. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ----- startup 15 14 13 12 11 10 9 8 ----- mode 76543210 -------osc32en table 9-9. startup time for 32 khz oscillator startup number of rc oscillator clock cycle approximative equivalent time (rcosc = 115 khz) 00 0 1128 1.1ms 2 8192 72.3 ms 3 16384 143 ms 4 65536 570 ms 5 131072 1.1 s 6 262144 2.3 s 7 524288 4.6 s
58 32059l?avr32?01/2012 at32uc3b 9.6.7 interrupt enable register name: ier access type: write-only offset: 0x040 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - - - - - - - boddet 15 14 13 12 11 10 9 8 - - - - - - osc32rdy osc1rdy 76543210 osc0rdy mskrdy ckrdy - - - lock1 lock0
59 32059l?avr32?01/2012 at32uc3b 9.6.8 interrupt disable register name: idr access type: write-only offset: 0x044 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - - - - - - - boddet 15 14 13 12 11 10 9 8 - - - - - - osc32rdy osc1rdy 76543210 osc0rdy mskrdy ckrdy - - - lock1 lock0
60 32059l?avr32?01/2012 at32uc3b 9.6.9 interrupt mask register name: imr access type: read-only offset: 0x048 reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. a bit in this register is cleared when the corresponding bit in idr is written to one. a bit in this register is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - - - - - - - boddet 15 14 13 12 11 10 9 8 - - - - - - osc32rdy osc1rdy 76543210 osc0rdy mskrdy ckrdy - - - lock1 lock0
61 32059l?avr32?01/2012 at32uc3b 9.6.10 interrupt status register name: isr access type: read-only offset: 0x04c reset value: 0x00000000 ? boddet: brown out detection set to 1 when 0 to 1 transition on poscsr:boddet bit is detected: bod has detected that power supply is going below bod reference value. ? osc32rdy: 32 khz oscillator ready set to 1 when 0 to 1 transition on the poscsr:osc32rdy bit is detected: the 32 khz oscillator is stable and ready to be used as clock source. ? osc1rdy: oscillator 1 ready set to 1 when 0 to 1 transition on the poscsr:osc1rdy bit is detected: oscillator 1 is stable a nd ready to be used as clock source. ? osc0rdy: oscillator 0 ready set to 1 when 0 to 1 transition on the poscsr:osc1rdy bit is detected: oscillator 1 is stable a nd ready to be used as clock source. ? mskrdy: mask ready set to 1 when 0 to 1 transition on the poscsr:mskrdy bit is detected: clocks are now masked according to the (cpu/hsb/pba/pbb)_m ask registers. ? ckrdy: clock ready 0: the cksel register has been written, a nd the new clock setting is not yet effective. 1: the synchronous clocks have frequencies as indicated in the cksel register. note: writing icr:ckrdy to 1 has no effect. ? lock1: pll1 locked set to 1 when 0 to 1 transition on the poscsr:lock1 bit is detected: pll 1 is locked and ready to be selected as clock source. ? lock0: pll0 locked set to 1 when 0 to 1 transition on the poscsr:lock0 bit is detected: pll 0 is locked and ready to be selected as clock source. ? ? 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - - - - - - - boddet 15 14 13 12 11 10 9 8 - - - - - - osc32rdy osc1rdy 76543210 osc0rdy mskrdy ckrdy - - - lock1 lock0
62 32059l?avr32?01/2012 at32uc3b 9.6.11 interrupt clear register name: icr access type: write-only offset: 0x050 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in isr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - - - - - - - boddet 15 14 13 12 11 10 9 8 - - - - - - osc32rdy osc1rdy 76543210 osc0rdy mskrdy ckrdy - - - lock1 lock0
63 32059l?avr32?01/2012 at32uc3b 9.6.12 power and oscillators status register name: poscsr access type: read-only offset: 0x054 reset value: 0x00000000 ? boddet: brown out detection 0: no bod event. 1: bod has detected that power supply is going below bod reference value. ? osc32rdy: 32 khz oscillator ready 0: the 32 khz oscillator is not enabled or not ready. 1: the 32 khz oscillator is stable and ready to be used as clock source. ? osc1rdy: osc1 ready 0: oscillator 1 not enabled or not ready. 1: oscillator 1 is stable and ready to be used as clock source. ? osc0rdy: osc0 ready 0: oscillator 0 not enabled or not ready. 1: oscillator 0 is stable and ready to be used as clock source. ? mskrdy: mask ready 0: mask register has been changed, masking in progress. 1: clock are masked according to xxx_mask. ? ckrdy: 0: the cksel register has been written, a nd the new clock setting is not yet effective. 1: the synchronous clocks have frequencies as indicated in the cksel register. ? lock1: pll 1 locked 0:pll 1 is unlocked. 1:pll 1 is locked, and ready to be selected as clock source. ? lock0: pll 0 locked 0: pll 0 is unlocked. 1: pll 0 is locked, and ready to be selected as clock source. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------boddet 15 14 13 12 11 10 9 8 ------osc32rdyosc1rdy 76543210 osc0rdy mskrdy ckrdy - - wake lock1 lock0
64 32059l?avr32?01/2012 at32uc3b 9.6.13 generic clock control register name: gcctrl access type: read/write offset: 0x060 - 0x070 reset value: 0x00000000 there is one gcctrl register per generic clock in the design. ? div: division factor ? diven: divide enable 0: the generic clock equals the undivided source clock. 1: the generic clock equals the source clock divided by 2*(div+1). ? cen: clock enable 0: clock is stopped. 1: clock is running. ? pllsel: pll select 0: oscillator is source for the generic clock. 1: pll is source for the generic clock. ? oscsel: oscillator select 0: oscillator (or pll) 0 is source for the generic clock. 1: oscillator (or pll) 1 is source for the generic clock. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 div[7:0] 76543210 - - - diven - cen pllsel oscsel
65 32059l?avr32?01/2012 at32uc3b 9.6.14 rc oscillator calibration register name: rccr access type : read/write offset: 0x0c0 reset value: - ? key: register write protection this field must be written twice, first with key value 0x55, then 0xaa, for a write operation to have an effect. ? calib: calibration value calibration value for the rc oscillator. ? fcd: flash calibration done ? set to 1 when the calib field has been updated by the flash fuses after power-on reset or flash fuses update. ? 0: allow subsequent overwriting of the calib value by flash fuses. ? 1: the calib value will not be updated again by flash fuses. 31 30 29 28 27 26 25 24 key 23 22 21 20 19 18 17 16 -------fcd 15 14 13 12 11 10 9 8 ------ calib[9:8] 76543210 calib[7:0]
66 32059l?avr32?01/2012 at32uc3b 9.6.15 bandgap calibration register name: bgcr access type: read/write offset: 0x0c4 reset value: - ? key: register write protection this field must be written twice, first with key value 0x55, then 0xaa, for a write operation to have an effect. ? calib: calibration value calibration value for bandgap. see electrical characteristics for voltage values. ? fcd: flash calibration done ? set to 1 when the calib field has been updated by the flash fuses after power-on reset or flash fuses update. ? 0: allow subsequent overwriting of the calib value by flash fuses. ? 1: the calib value will not be updated again by flash fuses. 31 30 29 28 27 26 25 24 key 23 22 21 20 19 18 17 16 -------fcd 15 14 13 12 11 10 9 8 -------- 76543210 ----- calib
67 32059l?avr32?01/2012 at32uc3b 9.6.16 voltage regulator calibration register name: :vregcr register access : read/write offset: 0x0c8 reset value: - ? key: register write protection ? this field must be written twice, first with key value 0x55, then 0xaa, for a write operation to have an effect. ? calib: calibration value ? calibration value for voltage regulator. the user can change this value to decrease or increase the voltage regulator output voltage. ? fcd: flash calibration done ? set to 1 when the calib field has been updated by the flash fuses after power-on reset or flash fuses update. ? 0: allow subsequent overwriting of the calib value by flash fuses. ? 1: the calib value will not be updated again by flash fuses. ? ? 31 30 29 28 27 26 25 24 key 23 22 21 20 19 18 17 16 -------fcd 15 14 13 12 11 10 9 8 -------- 76543210 ----- calib
68 32059l?avr32?01/2012 at32uc3b 9.6.17 bod level register name: bod access type: read/write offset: 0x0d0 reset value: - ? key: register write protection ? this field must be written twice, first with key value 0x55, then 0xaa, for a write operation to have an effect. ? fcd: bod fuse calibration done ? set to 1 when ctrl, hyst and level fi elds has been updated by the flash fuse s after power-on reset or flash fuses update. ? 0: allow subsequent overwriting of the value by flash fuses. ? 1: the ctrl, hyst and level values will not be updated again by flash fuses. ? ctrl: bod control ? 0: bod is off. ? 1: bod is enabled and can reset the chip. ? 2: bod is enabled and but cannot reset the chip. only interrupt will be sent to interrupt controller, if enabled in the imr register. ? 3: bod is off. ? hyst: bod hysteresis ? 0: no hysteresis ?1: hysteresis on ? level: bod level ? this field sets the triggering threshold of the bod. see electrical characteristics for actual voltage levels. ? note that any change to the level field of the bod register should be done with the bod deactivated to avoid spurious reset or interrupt. 31 30 29 28 27 26 25 24 key 23 22 21 20 19 18 17 16 -------fcd 15 14 13 12 11 10 9 8 ------ ctrl 76543210 - hyst level
69 32059l?avr32?01/2012 at32uc3b 9.6.18 reset cause register name: rcause access type: read-only offset: 0x140 reset value: latest reset source ? ocdrst: ocd reset ? the cpu was reset because the res strobe in the ocd development control register has been written to one. ?jtag: jtag reset ? the cpu was reset by setting the bit rc_cpu in the jtag reset register. ? wdt: watchdog reset ? the cpu was reset because of a watchdog time-out. ? ext: external reset pin ? the cpu was reset due to the reset pin being asserted. ? bod: brown-out reset ? the cpu was reset due to the supply voltage being lower than the brown-out threshold level. ? por power-on reset ? the cpu was reset due to the supply voltage being lower than the power-on threshold level. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------ocdrst 76543210 - - - jtag wdt ext bod por
70 32059l?avr32?01/2012 at32uc3b 9.6.19 asynchronous wake up enable register name: awen access type: read/write offset: 0x144 reset value: 0x00000000 ? ? usb_waken : usb wake up enable ? 0: the usb wake up is disabled. ? 1: the usb wake up is enabled. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------usb_waken
71 32059l?avr32?01/2012 at32uc3b 9.6.20 general purpose low-power register 0/1 name: gplp access type: read/write offset: 0x200 reset value: 0x00000000 these registers are general purpose 32-bit registers that are reset only by power-on-re set. any other reset will keep the conte nt of these registers untouched. user software can use these re gisters to save context variables in a very low power mode. two gplp register are implemented in at32uc3b. 31 30 29 28 27 26 25 24 data[31:24] 23 22 21 20 19 18 17 16 data[23:16] 15 14 13 12 11 10 9 8 data[15:8] 76543210 data[7:0]
72 32059l?avr32?01/2012 at32uc3b 10. real time counter (rtc) rev: 2.3.1.1 10.1 features ? 32-bit real-time counter with 16-bit prescaler ? clocked from rc oscillator or 32khz oscillator ? long delays ? max timeout 272years ? high resolution: max count frequency 16khz ? extremely low power consumption ? available in all sleep modes except static ? interrupt on wrap 10.2 overview the real time counter (rtc) enables periodic in terrupts at long intervals, or accurate mea- surement of real-time sequences. the rtc is fed from a 16-bit prescaler, which is clocked from the system rc oscillator or the 32khz crysta l oscillator. any tapping of the prescaler can be selected as clock source for the rtc, enabling both high resolution and long timeouts. the pres- caler cannot be written directly, but can be cleared by the user. the rtc can generate an interrupt when the counter wraps around the value stored in the top register (top), producing accurate periodic interrupts. 10.3 block diagram figure 10-1. real time counter block diagram 10.4 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 16-bit prescaler rcsys 32-bit counter val top topi irq clk_32 ctrl en clk32 psel 1 0
73 32059l?avr32?01/2012 at32uc3b 10.4.1 power management the rtc remains operating in all sleep modes exc ept static mode. interrupts are not available in deepstop mode. 10.4.2 clocks the rtc can use the system rc oscillator as cloc k source. this oscillator is always enabled whenever this module is active. please refer to the electrical characteristics chapter for the characteristic frequency of this oscillator (f rc ). the rtc can also use the 32 khz crystal oscilla tor as clock source. this oscillator must be enabled before use. please refer to the power manager chapter for details. the clock for the rtc bus interface (clk_rtc) is generated by the power manager. this clock is enabled at reset, and can be disabled in th e power manager. it is recommended to disable the rtc before disabling the clock, to avoid freezing the rtc in an undefined state. 10.4.3 interrupts the rtc interrupt request line is connected to the interrupt controller. using the rtc interrupt requires the interrupt controller to be programmed first. 10.4.4 debug operation the rtc prescaler is frozen during debug operation, unless the ocd system keeps peripherals running in debug operation. 10.5 functional description 10.5.1 rtc operation 10.5.1.1 source clock the rtc is enabled by writing a one to the enab le bit in the control register (ctrl.en). the 16-bit prescaler will then increment on the selected clock. the pres caler cannot be read or writ- ten, but it can be reset by writing a one to the prescaler clear bit in ct rl register (ctrl.pclr). the 32khz oscillator select bit in ctrl register (ctrl.clk32) selects ei ther the rc oscillator or the 32khz oscillator as clock source (defined as input in the formula below) for the prescaler. the prescale select field in ct rl register (ctrl.psel ) selects the prescale r tapping, selecting the source clock for the rtc: 10.5.1.2 counter operation when enabled, the rtc will increment until it r eaches top, and then wraps to 0x0. the status bit topi in interrupt status register (isr) is set to one when this occu rs. from 0x0 the counter will count top+1 cycles of the source clock before it wraps back to 0x0. f rtc f input 2 ? psel 1 + () =
74 32059l?avr32?01/2012 at32uc3b the rtc count value can be read from or written to the value register (val). due to synchroni- zation, continuous reading of the val register with the lowest pr escaler setting will skip every other value. 10.5.1.3 rtc interrupt the rtc interrupt is enabled by writing a one to the top interrupt bit in the interrupt enable reg- ister (ier.topi), and is disabled by writing a on e to the top interrupt bit in the interrupt disable register (idr.topi). the interrupt mask register (imr) can be read to see whether or not the interrupt is enabled. if enabled, an interrupt will be generated if t he topi bit in th e interrupt sta- tus register (isr) is set. the topi bit in isr c an be cleared by writing a one to the topi bit in the interrupt clear re gister (icr.topi). the rtc interrupt can wake the cpu from all sl eep modes except deepstop and static modes. 10.5.1.4 rtc wakeup the rtc can also wake up the cpu directly wi thout triggering an interrupt when the isr.topi bit is set. in this case, the cpu will continue executing from t he instruction following the sleep instruction. this direct rtc wake-up is enabl ed by writing a one to the wake enable bit in the ctrl register (ctrl.waken). when the cpu wakes from sleep, the ctrl.waken bit must be written to zero to clear the internal wake signal to the sleep controller, otherwise a new sleep instruction will have no effect. the rtc wakeup is available in all sleep modes except static mode. the rtc wakeup can be configured independently of the rtc interrupt. 10.5.1.5 busy bit due to the crossing of clock domains, the rtc us es a few clock cycles to propagate the values stored in ctrl, top, and val to the rtc. the rtc busy bit in ctrl (ctrl.busy) indicates that a register write is still go ing on and all writes to top, ctrl, and val will be discarded until the ctrl.busy bit goes low again.
75 32059l?avr32?01/2012 at32uc3b 10.6 user interface table 10-1. rtc register memory map offset register register name access reset 0x00 control register ctrl read/write 0x00010000 0x04 value register val read/write 0x00000000 0x08 top register top read/write 0xffffffff 0x10 interrupt enable register ier write-only 0x00000000 0x14 interrupt disable register idr write-only 0x00000000 0x18 interrupt mask register imr read-only 0x00000000 0x1c interrupt status register isr read-only 0x00000000 0x20 interrupt clear register icr write-only 0x00000000
76 32059l?avr32?01/2012 at32uc3b 10.6.1 control register name: ctrl access type: read/write offset: 0x00 reset value: 0x00010000 ? clken: clock enable 1: the clock is enabled. 0: the clock is disabled. ? psel: prescale select selects prescaler bit psel as source clock for the rtc. ? busy: rtc busy this bit is set when the rtc is busy and will discard writes to top, val, and ctrl. this bit is cleared when the rtc accepts writes to top, val, and ctrl. ? clk32: 32 khz oscillator select 1: the rtc uses the 32 khz oscillator as clock source. 0: the rtc uses the rc oscillator as clock source. ? waken: wakeup enable 1: the rtc wakes up the cpu from sleep modes. 0: the rtc does not wake up the cpu from sleep modes. ? pclr: prescaler clear writing a one to this bit clears the prescaler. writing a zero to this bit has no effect. this bit always reads as zero. ?en: enable 1: the rtc is enabled. 0: the rtc is disabled. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------clken 15 14 13 12 11 10 9 8 - - - - psel 76543210 - - - busy clk32 waken pclr en
77 32059l?avr32?01/2012 at32uc3b 10.6.2 value register name: val access type: read/write offset: 0x04 reset value: 0x00000000 ? val[31:0]: rtc value this value is incremented on every rising edge of the source clock. 31 30 29 28 27 26 25 24 val[31:24] 23 22 21 20 19 18 17 16 val[23:16] 15 14 13 12 11 10 9 8 val[15:8] 76543210 val[7:0]
78 32059l?avr32?01/2012 at32uc3b 10.6.3 top register name: top access type: read/write offset: 0x08 reset value: 0xffffffff ? val[31:0]: rtc top value val wraps at this value. 31 30 29 28 27 26 25 24 val[31:24] 23 22 21 20 19 18 17 16 val[23:16] 15 14 13 12 11 10 9 8 val[15:8] 76543210 val[7:0]
79 32059l?avr32?01/2012 at32uc3b 10.6.4 interrupt enable register name: ier access type: write-only offset: 0x10 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------topi
80 32059l?avr32?01/2012 at32uc3b 10.6.5 interrupt disable register name: idr access type: write-only offset: 0x14 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------topi
81 32059l?avr32?01/2012 at32uc3b 10.6.6 interrupt mask register name: imr access type: read-only offset: 0x18 reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. a bit in this register is cleared when the corresponding bit in idr is written to one. a bit in this register is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------topi
82 32059l?avr32?01/2012 at32uc3b 10.6.7 interrupt status register name: isr access type: read-only offset: 0x1c reset value: 0x00000000 ? topi: top interrupt this bit is set when val has wrapped at its top value. this bit is cleared when the corresponding bit in icr is written to one. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------topi
83 32059l?avr32?01/2012 at32uc3b 10.6.8 interrupt clear register name: icr access type: write-only offset: 0x20 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in sr and the corresponding interrupt request. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------topi
84 32059l?avr32?01/2012 at32uc3b 11. watchdog timer (wdt) rev: 2.3.1.1 11.1 features ? watchdog timer counter with 32-bit prescaler ? clocked from the system rc oscillator (rcsys) 11.2 overview the watchdog timer (wdt) has a prescaler gener ating a time-out period. this prescaler is clocked from the rc oscillator. th e watchdog timer must be periodic ally reset by software within the time-out period, otherwise, th e device is reset and starts exec uting from the boot vector. this allows the device to recover from a conditi on that has caused the system to be unstable. 11.3 block diagram figure 11-1. wdt block diagram 11.4 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 11.4.1 power management when the wdt is enabled, the wdt remains clocked in all sleep modes, and it is not possible to enter static mode. 11.4.2 clocks the wdt can use the system rc o scillator (rcsys) as clock sour ce. this oscillator is always enabled whenever these modules are active. please refer to the electrical characteristics chap- ter for the characteristic fr equency of this oscillator (f rc ). 11.4.3 debug operation the wdt prescaler is frozen during debug opera tion, unless the on-chip debug (ocd) system keeps peripherals running in debug operation. rcsys clr watchdog detector ctrl 32-bit prescaler watchdog reset en
85 32059l?avr32?01/2012 at32uc3b 11.5 functional description the wdt is enabled by writing a one to the enable bit in the control register (ctrl.en). this also enables the system rc clock (clk_rcsys) fo r the prescaler. the pr escale select field (psel) in the ctrl register selects the watchdog time-out period: t wdt = 2 (psel+1) / f rc the next time-out period will b egin as soon as the watchdog re set has occurred and count down during the reset sequence. care must be taken w hen selecting the psel field value so that the time-out period is greater than the startup time of the chip, otherwise a watchdog reset can reset the chip before any code has been run. to avoid accidental disabling of the watchdog, the ctrl register mu st be written twice, first with the key field set to 0x55, then 0x aa without changing the other bi ts. failure to do so will cause the write operation to be ignored, an d the ctrl register value will not change. the clear register (clr) must be written with any value with regular intervals shorter than the watchdog time-out period. otherwise, the device will receive a soft reset, and the code will start executing from the boot vector. when the wdt is enabled, it is not possible to enter static mo de. attempting to do so will result in entering shutdown mode, leaving the wdt operational. 11.6 user interface table 11-1. wdt register memory map offset register register name access reset 0x00 control register ctrl read/write 0x00000000 0x04 clear register clr write-only 0x00000000
86 32059l?avr32?01/2012 at32uc3b 11.6.1 control register name: ctrl access type: read/write offset: 0x00 reset value: 0x00000000 ? key: write protection key this field must be written twice, first with key value 0x55, then 0xaa, for a write operation to be effective. this field always reads as zero. ? psel: prescale select psel is used as watchdog timeout period. ? en: wdt enable 1: wdt is enabled. 0: wdt is disabled. 31 30 29 28 27 26 25 24 key 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - - psel 76543210 -------en
87 32059l?avr32?01/2012 at32uc3b 11.6.2 clear register name: clr access type: write-only offset: 0x04 reset value: 0x00000000 ?clr: writing periodically any value to this field when the wdt is enabled, within the watchdog time-out period, will prevent a watchdog reset. this field always reads as zero. 31 30 29 28 27 26 25 24 clr[31:24] 23 22 21 20 19 18 17 16 clr[23:16] 15 14 13 12 11 10 9 8 clr[15:8] 76543210 clr[7:0]
88 32059l?avr32?01/2012 at32uc3b 12. interrupt controller (intc) rev: 1.0.1.5 12.1 features ? autovectored low latency interrupt service with programmable priority ? 4 priority levels for regu lar, maskable interrupts ? one non-maskable interrupt ? up to 64 groups of interrupts with up to 32 interrupt requests in each group 12.2 overview the intc collects interrupt requests from the peripherals, prioritizes them, and delivers an inter- rupt request and an autovector to the cpu. the avr32 architecture supports 4 priority levels for regular, maskable interrupts, and a non-maskable interrupt (nmi). the intc supports up to 64 groups of interrupts. each group can have up to 32 interrupt request lines, these lines are connected to the peripheral s. each group has an interrupt priority register (ipr) and an interrupt request register (irr). the iprs are used to assign a priority level and an autovector to each group, and the irrs are used to identify the active interrupt request within each group. if a group has only one interrupt request line, an active interrupt group uniquely identifies the active interrupt request line, and the corresponding irr is not needed. the intc also provides one interrupt cause register (icr) per priority level. these registers identify the group that has a pending interrupt of the corresponding priority level. if several groups have a pending interrupt of the same level, the gr oup with the lowest nu mber takes priority. 12.3 block diagram figure 12-1 gives an overview of the intc. the grey boxes represent registers that can be accessed via the user interface. the interrupt requests from the peripherals (ireqn) and the nmi are input on the left side of the figure. sign als to and from the cpu are on the right side of the figure.
89 32059l?avr32?01/2012 at32uc3b figure 12-1. intc block diagram 12.4 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 12.4.1 power management if the cpu enters a sleep mode that disables clk_sync, the intc will stop functioning and resume operation after the system wakes up from sleep mode. 12.4.2 clocks the clock for the intc bus interface (clk_int c) is generated by the power manager. this clock is enabled at reset, and can be disabled in the power manager. the intc sampling logic runs on a clock which is stopped in any of the sleep modes where the system rc oscillator is not r unning. this clock is referred to as clk_sync. this clock is enabled at reset, and only turned off in sleep modes wher e the system rc oscillator is stopped. 12.4.3 debug operation when an external debugger forces the cpu into debug mode, the intc continues normal operation. 12.5 functional description all of the incoming interrupt requests (ireqs) are sampled into the corresponding interrupt request register (irr). the irrs must be accesse d to identify which ireq within a group that is active. if several ireqs within the same gr oup are active, the interrupt service routine must prioritize between them. all of the input lines in each group are logically ored together to form the grpreqn lines, indicating if there is a pending interrupt in the corresponding group. the request masking hardware maps each of the grpreq lines to a priority level from int0 to int3 by associating each grou p with the interrupt level (int level) field in the corresponding request masking or ireq0 ireq1 ireq2 ireq31 grpreq0 masks sreg masks i[3-0]m gm intlevel autovector prioritizer cpu interrupt controller or grpreqn nmireq or ireq32 ireq33 ireq34 ireq63 grpreq1 irr registers ipr registers icr registers int_level, offset int_level, offset int_level, offset ipr0 ipr1 iprn irr0 irr1 irrn valreq0 valreq1 valreqn . . . . . . . . .
90 32059l?avr32?01/2012 at32uc3b interrupt priority regist er (ipr). the grpreq inputs are then masked by the mask bits from the cpu status register. any interrupt group that has a pending interrupt of a priority level that is not masked by the cpu status register, get s its corresponding valreq line asserted. masking of the interrupt requests is done based on five interrupt mask bits of the cpu status register, namely interrupt level 3 mask (i3m) to interrupt level 0 mask (i0m), and global inter- rupt mask (gm). an interrupt request is masked if either the gm or the corresponding interrupt level mask bit is set. the prioritizer hardware uses th e valreq lines and the intlevel fi eld in the iprs to select the pending interrupt of the highest priority. if an nm i interrupt request is pending, it automatically gets the highest priority of any pending interrupt. if several interrupt groups of the highest pend- ing interrupt level have pending interrupts, the interrupt group with the lowest number is selected. the intlevel and handler autovector offset (a utovector) of the selected interrupt are transmitted to the cpu for inte rrupt handling and context switch ing. the cpu does not need to know which interrupt is requesting handling, but only the level and the offset of the handler address. the irr registers contai n the interrupt request lines of the groups and can be read via user interface registers for checking which interrupts of the group are actually active. the delay through the intc from the peripheral interrupt request is set until the interrupt request to the cpu is set is three cycles of clk_sync. 12.5.1 non-maskable interrupts a nmi request has priority over all other inte rrupt requests. nmi has a dedicated exception vec- tor address defined by the avr32 architec ture, so autovector is undefined when intlevel indicates that an nmi is pending. 12.5.2 cpu response when the cpu receives an interr upt request it checks if any othe r exceptions are pending. if no exceptions of higher prio rity are pending, interrupt handling is initiated. when initiating interrupt handling, the corresponding interrupt mask bit is se t automatically for this and lower levels in sta- tus register. e.g, if an interrup t of level 3 is approved for hand ling, the interrupt mask bits i3m, i2m, i1m, and i0m are set in status register. if an interrupt of level 1 is approved, the masking bits i1m and i0m are set in status register. th e handler address is calculated by logical or of the autovector to the cpu system register exception vector base address (evba). the cpu will then jump to the calculated address and start executing th e interrupt handler. setting the interrupt mask bits prevents the in terrupts from the same and lower levels to be passed through the interrupt controller. setting of the same level mask bit prevents also multiple requests of the same interrupt to happen. it is the responsibility of the ha ndler software to clear the interrupt request that caused the inter- rupt before returning from the interrupt handler. if the conditions that caused the interrupt are not cleared, the interrupt request remains active. 12.5.3 clearing an interrupt request clearing of the interrupt request is done by writ ing to registers in the corresponding peripheral module, which then clears the corresponding nmireq/ireq signal. the recommended way of clearing an interrupt reques t is a store operation to the controlling peripheral register, followed by a dummy load operat ion from the same register. this causes a
91 32059l?avr32?01/2012 at32uc3b pipeline stall, which prevents the interrupt from accidentally re-triggering in case the handler is exited and the interrupt mask is cleare d before the interrupt request is cleared.
92 32059l?avr32?01/2012 at32uc3b 12.6 user interface table 12-1. intc register memory map offset register register name access reset 0x000 interrupt priority register 0 ipr0 read/write 0x00000000 0x004 interrupt priority register 1 ipr1 read/write 0x00000000 ... ... ... ... ... 0x0fc interrupt priority register 63 ipr63 read/write 0x00000000 0x100 interrupt request register 0 irr0 read-only n/a 0x104 interrupt request register 1 irr1 read-only n/a ... ... ... ... ... 0x1fc interrupt request register 63 irr63 read-only n/a 0x200 interrupt cause register 3 icr3 read-only n/a 0x204 interrupt cause register 2 icr2 read-only n/a 0x208 interrupt cause register 1 icr1 read-only n/a 0x20c interrupt cause register 0 icr0 read-only n/a
93 32059l?avr32?01/2012 at32uc3b 12.6.1 interrupt priority registers name : ipr0...ipr63 access type: read/write offset: 0x000 - 0x0fc reset value: 0x00000000 ? intlevel: interrupt level indicates the evba-relative offset of the in terrupt handler of the corresponding group: 00: int0: lowest priority 01: int1 10: int2 11: int3: highest priority ? autovector: autovector address handler offset is used to give the address of the interrupt handler. the least significant bit should be written to zero to giv e halfword alignment. 31 30 29 28 27 26 25 24 intlevel ------ 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - autovector[13:8] 76543210 autovector[7:0]
94 32059l?avr32?01/2012 at32uc3b 12.6.2 interrupt request registers name : irr0...irr63 access type: read-only offset: 0x0ff - 0x1fc reset value: n/a ? irr: interrupt request line this bit is cleared when no interrupt requ est is pending on this input request line. this bit is set when an interrupt request is pending on this input request line. the are 64 irrs, one for each group. each irr has 32 bits, one for each possible interrupt request, for a total of 2048 possibl e input lines. the irrs are read by the software interrupt handler in order to determine which interrupt request is pending. the irrs are sampled continuously, and are read-only. 31 30 29 28 27 26 25 24 irr[32*x+31] irr[32*x+30] irr[32*x+29] irr[32*x+28] irr[32*x+27] irr[32*x+26] irr[32*x+25] irr[32*x+24] 23 22 21 20 19 18 17 16 irr[32*x+23] irr[32*x+22] irr[32*x+21] irr[32*x+20] irr[32*x+19] irr[32*x+18] irr[32*x+17] irr[32*x+16] 15 14 13 12 11 10 9 8 irr[32*x+15] irr[32*x+14] irr[32*x+13] irr[32*x+12] irr[32*x+11] irr[32*x+10] irr[32*x+9] irr[32*x+8] 76543210 irr[32*x+7] irr[32*x+6] irr[32*x+5] irr[32*x+4] irr[32*x+3] irr[32*x+2] irr[32*x+1] irr[32*x+0]
95 32059l?avr32?01/2012 at32uc3b 12.6.3 interrupt cause registers name : icr0...icr3 access type: read-only offset: 0x200 - 0x20c reset value: n/a ? cause: interrupt group causing interrupt of priority n icrn identifies the group with the highest priority that has a pending interrupt of level n. this value is only defined when at least one interrupt of level n is pending. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - cause
96 32059l?avr32?01/2012 at32uc3b 12.7 interrupt request signal map the various modules may output interrupt request signals. these signals are routed to the inter- rupt controller (intc), described in a later chapter. the interrupt controller supports up to 64 groups of interrupt requests. each group can have up to 32 interrupt request signals. all interrupt signals in the same group share the same autov ector address and priority level. refer to the documentation for the individual submodules for a description of the semantics of the different interrupt requests. the interrupt request signals are connected to the intc as follows. table 12-2. interrupt requ est signal map group line module signal 00 avr32 uc cpu with optional mpu and optional ocd sysreg compare 1 0 external interrupt controller eic 0 1 external interrupt controller eic 1 2 external interrupt controller eic 2 3 external interrupt controller eic 3 4 external interrupt controller eic 4 5 external interrupt controller eic 5 6 external interrupt controller eic 6 7 external interrupt controller eic 7 8 real time counter rtc 9 power manager pm 2 0 general purpose input/output controller gpio 0 1 general purpose input/output controller gpio 1 2 general purpose input/output controller gpio 2 3 general purpose input/output controller gpio 3 4 general purpose input/output controller gpio 4 5 general purpose input/output controller gpio 5 3 0 peripheral dma controller pdca 0 1 peripheral dma controller pdca 1 2 peripheral dma controller pdca 2 3 peripheral dma controller pdca 3 4 peripheral dma controller pdca 4 5 peripheral dma controller pdca 5 6 peripheral dma controller pdca 6 4 0 flash controller flashc 50 universal synchronous/asynchronous receiver/transmitter usart0
97 32059l?avr32?01/2012 at32uc3b 60 universal synchronous/asynchronous receiver/transmitter usart1 70 universal synchronous/asynchronous receiver/transmitter usart2 9 0 serial peripheral interface spi 11 0 two-wire interface twi 12 0 pulse width modulation controller pwm 13 0 synchronous serial controller ssc 14 0 timer/counter tc0 1 timer/counter tc1 2 timer/counter tc2 15 0 analog to digital converter adc 17 0 usb 2.0 interface usbb 18 0 audio bitstream dac abdac table 12-2. interrupt requ est signal map
98 32059l?avr32?01/2012 at32uc3b 13. external interrupt controller (eic) rev: 2.3.1.0 13.1 features ? dedicated interrupt request for each interrupt ? individually maskable interrupts ? interrupt on rising or falling edge ? interrupt on high or low level ? asynchronous interrupts for sleep modes without clock ? filtering of interrupt lines ? maskable nmi interrupt ? keypad scan support 13.2 overview the external interrupt controller (eic) allows pins to be configured as external interrupts. each external interrupt has its own interrupt reques t and can be individually masked. each external interrupt can generate an interrupt on rising or falling edge, or high or low level. every interrupt input has a configurable filter to remove spikes from the interrupt source. every interrupt pin can also be configured to be asynchronous in order to wake up the part from sleep modes where the clk_sync clock has been disabled. a non-maskable interrupt (nmi) is also supported. this has the same properties as the other external interrupts, but is connected to the nm i request of the cpu, enabling it to interrupt any other interrupt mode. the eic can wake up the part from sleep modes without triggering an interrupt. in this mode, code execution starts from the inst ruction following the sleep instruction. the external interrupt controller has support for keypad scanning for keypads laid out in rows and columns. columns are driven by a separate set of scanning outputs, while rows are sensed by the external interrupt lines. the pressed key will trigger an interrupt, which can be identified through the user registers of the module.
99 32059l?avr32?01/2012 at32uc3b 13.3 block diagram figure 13-1. eic block diagram 13.4 i/o lines description 13.5 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 13.5.1 i/o lines the external interrupt pins (extintn and nmi) are multiplexed with i/o lines. to generate an external interrupt from an external source the s ource pin must be configur ed as an input pins by the i/o controller. it is also poss ible to trigger the interrupt by dr iving these pins from registers in the i/o controller, or another peripheral output connected to the same pin. 13.5.2 power management all interrupts are available in all sleep modes as long as the eic module is powered. however, in sleep modes where clk_sync is stopped, the interrupt must be configured to asynchronous mode. edge/level detector mask ir q n extintn nmi in t n level mode edge ie r id r ic r ctrl is r im r f ilte r filter polarity control level mode edge asynchronus detector eic_w ake enable en dis ctrl clk_sync wake detect async prescaler shifter presc en scan pin scanm clk_rcsys table 13-1. i/o lines description pin name pin description type nmi non-maskable interrupt input extintn external interrupt input scanm keypad scan pin m output
100 32059l?avr32?01/2012 at32uc3b 13.5.3 clocks the clock for the eic bus interface (clk_eic) is generated by the power manager. this clock is enabled at reset, and can be disabled in the power manager. the filter and synchronous edge/level detector runs on a clock which is stopped in any of the sleep modes where the system rc oscillator is not running. th is clock is referred to as clk_sync. refer to the module configuration section at the end of this chapter for details. the keypad scan function ope rates on the system rc oscillator clock clk_rcsys. 13.5.4 interrupts the external interrupt request lines are connected to the interrupt controller. using the external interrupts requires the interrupt controller to be programmed first. using the non-maskable interrupt does not require the interrupt controller to be programmed. 13.5.5 debug operation the eic is frozen during debug operation, unless the ocd system keeps peripherals running during debug operation. 13.6 functional description 13.6.1 external interrupts the external interrupts are not enabled by default, allowing the proper interrupt vectors to be set up by the cpu before the interrupts are enabled. each external interrupt intn can be configured to prod uce an interrup t on rising or falling edge, or high or low level. external interrupts ar e configured by the mode, edge, and level regis- ters. each interrupt n has a bit intn in each of t hese registers. writing a zero to the intn bit in the mode register enables edge triggered interrup ts, while writing a one to the bit enables level triggered interrupts. if intn is configured as an edge triggered interr upt, writing a zero to the intn bit in the edge register will cause the interrupt to be triggered on a falling edg e on extintn, while writing a one to the bit will cause the in terrupt to be triggered on a rising edge on extintn. if intn is configured as a leve l triggered interrupt, writing a zero to the intn bit in the level register will cause the interrupt to be triggered on a low level on extintn, while writing a one to the bit will cause the interrupt to be triggered on a high level on extintn. each interrupt has a corresponding bit in each of the interrupt control and status registers. writ- ing a one to the intn bit in the interrupt enabl e register (ier) enables the external interrupt from pin extintn to propagate from the eic to the interrupt controller, while writing a one to intn bit in the interrupt disable register (idr) disables this propagation. the interrupt mask register (imr) can be read to check which interrupts are en abled. when an interrupt triggers, the corresponding bit in th e interrupt status register (isr) will be set. this bit remains set until a one is written to the corresponding bit in the inte rrupt clear register (icr) or the interrupt is disabled. writing a one to the intn bit in the enable register (en) enables the external interrupt on pin extintn, while writing a one to intn bit in the disable register (dis) disables the external inter- rupt. the control register (ctrl) can be read to check which interrupts are enabled. if a bit in the ctrl register is set, but the corresponding bi t in imr is not set, an interrupt will not propa-
101 32059l?avr32?01/2012 at32uc3b gate to the interrupt controller. however, the corresponding bit in isr will be set, and eic_wake will be set. if the ctrl.intn bit is zero, then the correspondin g bit in isr will always be zero. disabling an external interrupt by writing to the dis.intn bit will cl ear the correspond ing bit in isr. 13.6.2 synchronization and filtering of external interrupts in synchronous mode the pin value of the ex tintn pin is synchronized to clk_sync, so spikes shorter than one clk_sync cycle are not guaranteed to produce an interrupt. the syn- chronization of the extintn to clk_sync will delay the propagation of the interrupt to the interrupt controller by two cycles of clk_sync, see figure 13-2 on page 101 and figure 13-3 on page 101 for examples (filter off). it is also possible to apply a filter on extintn by writing a one to intn bit in the filter register. this filter is a majority voter, if the condition for an interrupt is true for more than one of the latest three cycles of clk_sync the interrupt will be se t. this will additionally delay the pr opagation of the interrupt to the interrupt controller by one or two cycles of clk_sync, see figure 13-2 on page 101 and figure 13-3 on page 101 for examples (filter on). figure 13-2. timing diagram, synchronous interrupts, high level or rising edge figure 13-3. timing diagram, synchrono us interrupts, low level or falling edge extintn/nmi clk_sync isr.intn: filter off isr.intn: filter on extintn/nmi clk_sync isr.intn: filter off isr.intn: filter on
102 32059l?avr32?01/2012 at32uc3b 13.6.3 non-maskable interrupt the nmi supports the same features as the external interrupts, and is accessed through the same registers. th e description in section 13.6.1 should be followed, accessing the nmi bit instead of the intn bits. the nmi is non-maskable within the cpu in the sense that it can interrupt any other execution mode. still, as for the other exte rnal interrupts, the actual nmi input can be enabl ed and disabled by accessing the registers in the eic. 13.6.4 asynchronous interrupts each external inte rrupt can be made asynchronous by wr iting a one to intn in the async reg- ister. this will route the interrupt signal through the asynchronous path of the module. all edge interrupts will be interpreted as leve l interrupts and the f ilter is disabled. if an interrupt is config- ured as edge triggered interr upt in asynchronous mode, a zero in edge.intn will be interpreted as low level, and a one in edge.intn will be interpreted as high level. eic_wake will be set immediately after the source triggers the interrupt, while the correspond- ing bit in isr and the interrupt to the interrupt controller will be set on the next rising edge of clk_sync. please refere to figure 13-4 on page 102 for details. when clk_sync is stopped only asynchronous interrupts remain active, and any short spike on this interrupt will wake up the device. eic_wake will re start clk_sync and isr will be updated on the first rising edge of clk_sync. figure 13-4. timing diagram, asynchronous interrupts 13.6.5 wakeup the external interrupts can be used to wake up the part from sleep modes. the wakeup can be interpreted in two ways. if the corresponding bit in imr is one, then the execution starts at the interrupt handler for this interrupt. if the bit in im r is zero, then the execution starts from the next instruction after the sleep instruction. extintn/nmi clk_sync isr.intn: rising edge or high level eic_wake: rising edge or high level extintn/nmi clk_sync isr.intn: rising edge or high level eic_wake: rising edge or high level
103 32059l?avr32?01/2012 at32uc3b 13.6.6 keypad scan support the external interrupt controller also inclu des support for keypad scanning. the keypad scan feature is compatible with keypads organized as rows and columns, where a row is shorted against a column when a key is pressed. the rows should be connected to the external interrupt pins with pull-ups enabled in the i/o con- troller. these external interrupts should be enabl ed as low level or falling edge interrupts. the columns should be connected to the available scan pins. the i/o cont roller must be configured to let the required scan pins be controlled by the eic. unused external interrupt or scan pins can be left controlled by the i/o controller or other peripherals. the keypad scan function is enabled by writing sc an.en to 1, which starts the keypad scan counter. the scan outputs are tri-stated, except scan[0], which is driven to zero. after 2 (scan.presc+1) rc clock cycles this pattern is left shifte d, so that scan[1] is driven to zero while the other outputs are tri- stated. this sequence re peats infinitely, wrapping from the most signifi- cant scan pin to scan[0]. when a key is pressed, the pulled-up row is driven to zero by the column, and an external inter- rupt triggers. the scanning stops, and the software can then identify the key pressed by the interrupt status register and the scan.pins value. the scanning stops whenever there is an active interrupt request from the eic to the cpu. when the cpu clears the interrupt flags, scanning resumes.
104 32059l?avr32?01/2012 at32uc3b 13.7 user interface table 13-2. eic register memory map offset register register name access reset 0x000 interrupt enable register ier write-only 0x00000000 0x004 interrupt disable register idr write-only 0x00000000 0x008 interrupt mask register imr read-only 0x00000000 0x00c interrupt status register isr read-only 0x00000000 0x010 interrupt clear register icr write-only 0x00000000 0x014 mode register mode read/write 0x00000000 0x018 edge register edge read/write 0x00000000 0x01c level register level read/write 0x00000000 0x020 filter register filter read/write 0x00000000 0x024 test register test read/write 0x00000000 0x028 asynchronous register async read/write 0x00000000 0x2c scan register scan read/write 0x00000000 0x030 enable register en write-only 0x00000000 0x034 disable register dis write-only 0x00000000 0x038 control register ctrl read-only 0x00000000
105 32059l?avr32?01/2012 at32uc3b 13.7.1 interrupt enable register name: ier access type: write-only offset: 0x000 reset value: 0x00000000 ?intn: external interrupt n writing a zero to this bit has no effect. writing a one to this bit will set the corresponding bit in imr. ? nmi: non-maskab le interrupt writing a zero to this bit has no effect. writing a one to this bit will set the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------nmi 76543210 int7 int6 int5 int4 int3 int2 int1 int0
106 32059l?avr32?01/2012 at32uc3b 13.7.2 interrupt disable register name: idr access type: write-only offset: 0x004 reset value: 0x00000000 ?intn: external interrupt n writing a zero to this bit has no effect. writing a one to this bit will clear the corresponding bit in imr. ? nmi: non-maskab le interrupt writing a zero to this bit has no effect. writing a one to this bit will clear the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------nmi 76543210 int7 int6 int5 int4 int3 int2 int1 int0
107 32059l?avr32?01/2012 at32uc3b 13.7.3 interrupt mask register name: imr access type: read-only offset: 0x008 reset value: 0x00000000 ?intn: external interrupt n 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. this bit is cleared when the corresponding bit in idr is written to one. this bit is set when the corresponding bit in ier is written to one. ? nmi: non-maskab le interrupt 0: the non-maskable interrupt is disabled. 1: the non-maskable interrupt is enabled. this bit is cleared when the corresponding bit in idr is written to one. this bit is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------nmi 76543210 int7 int6 int5 int4 int3 int2 int1 int0
108 32059l?avr32?01/2012 at32uc3b 13.7.4 interrupt status register name: isr access type: read-only offset: 0x00c reset value: 0x00000000 ?intn: external interrupt n 0: an interrupt event has not occurred 1: an interrupt event has occurred this bit is cleared by writing a one to the corresponding bit in icr. ? nmi: non-maskab le interrupt 0: an interrupt event has not occurred 1: an interrupt event has occurred this bit is cleared by writing a one to the corresponding bit in icr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------nmi 76543210 int7 int6 int5 int4 int3 int2 int1 int0
109 32059l?avr32?01/2012 at32uc3b 13.7.5 interrupt clear register name: icr access type: write-only offset: 0x010 reset value: 0x00000000 ?intn: external interrupt n writing a zero to this bit has no effect. writing a one to this bit will clear the corresponding bit in isr. ? nmi: non-maskab le interrupt writing a zero to this bit has no effect. writing a one to this bit will clear the corresponding bit in isr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------nmi 76543210 int7 int6 int5 int4 int3 int2 int1 int0
110 32059l?avr32?01/2012 at32uc3b 13.7.6 mode register name: mode access type: read/write offset: 0x014 reset value: 0x00000000 ?intn: external interrupt n 0: the external interrupt is edge triggered. 1: the external interrupt is level triggered. ? nmi: non-maskab le interrupt 0: the non-maskable interrupt is edge triggered. 1: the non-maskable interrupt is level triggered. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------nmi 76543210 int7 int6 int5 int4 int3 int2 int1 int0
111 32059l?avr32?01/2012 at32uc3b 13.7.7 edge register name: edge access type: read/write offset: 0x018 reset value: 0x00000000 ?intn: external interrupt n 0: the external interrupt triggers on falling edge. 1: the external interrupt triggers on rising edge. ? nmi: non-maskab le interrupt 0: the non-maskable interrupt triggers on falling edge. 1: the non-maskable interrupt triggers on rising edge. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------nmi 76543210 int7 int6 int5 int4 int3 int2 int1 int0
112 32059l?avr32?01/2012 at32uc3b 13.7.8 level register name: level access type: read/write offset: 0x01c reset value: 0x00000000 ?intn: external interrupt n 0: the external interrupt triggers on low level. 1: the external interrupt triggers on high level. ? nmi: non-maskab le interrupt 0: the non-maskable interrupt triggers on low level. 1: the non-maskable interrupt triggers on high level. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------nmi 76543210 int7 int6 int5 int4 int3 int2 int1 int0
113 32059l?avr32?01/2012 at32uc3b 13.7.9 filter register name: filter access type: read/write offset: 0x020 reset value: 0x00000000 ?intn: external interrupt n 0: the external interrupt is not filtered. 1: the external interrupt is filtered. ? nmi: non-maskab le interrupt 0: the non-maskable interrupt is not filtered. 1: the non-maskable interrupt is filtered. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------nmi 76543210 int7 int6 int5 int4 int3 int2 int1 int0
114 32059l?avr32?01/2012 at32uc3b 13.7.10 test register name: test access type: read/write offset: 0x024 reset value: 0x00000000 ? testen: test enable 0: this bit disables external interrupt test mode. 1: this bit enables external interrupt test mode. ?intn: external interrupt n if testen is 1, the value written to this bit will be the value to the interrupt detector and the value on the pad will be igno red. ? nmi: non-maskab le interrupt if testen is 1, the value written to this bit will be the value to the interrupt detector and the value on the pad will be igno red. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------nmi 76543210 int7 int6 int5 int4 int3 int2 int1 int0
115 32059l?avr32?01/2012 at32uc3b 13.7.11 asynchronous register name: async access type: read/write offset: 0x028 reset value: 0x00000000 ?intn: external interrupt n 0: the external interrupt is synchronized to clk_sync. 1: the external interrupt is asynchronous. ? nmi: non-maskab le interrupt 0: the non-maskable interrupt is synchronized to clk_sync 1: the non-maskable interrupt is asynchronous. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------nmi 76543210 int7 int6 int5 int4 int3 int2 int1 int0
116 32059l?avr32?01/2012 at32uc3b 13.7.12 scan register name: scan access type: read/write offset: 0x2c reset value: 0x0000000 ? en 0: keypad scanning is disabled 1: keypad scanning is enabled ? presc prescale select for the keypad scan rate: scan rate = 2 (scan.presc+1) t rc the rc clock period can be found in the electrical characteristics section. ? pin the index of the currently active scan pin. writing to this bitfield has no effect. 31 30 29 28 27 26 25 24 - - - - - pin[2:0] 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - - presc[4:0] 76543210 -------en
117 32059l?avr32?01/2012 at32uc3b 13.7.13 enable register name: en access type: write-only offset: 0x030 reset value: 0x00000000 ?intn: external interrupt n writing a zero to this bit has no effect. writing a one to this bit will enable the corresponding external interrupt. ? nmi: non-maskab le interrupt writing a zero to this bit has no effect. writing a one to this bit will enable the non-maskable interrupt. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------nmi 76543210 int7 int6 int5 int4 int3 int2 int1 int0
118 32059l?avr32?01/2012 at32uc3b 13.7.14 disable register name: dis access type: write-only offset: 0x034 reset value: 0x00000000 ?intn: external interrupt n writing a zero to this bit has no effect. writing a one to this bit will disable the corresponding external interrupt. ? nmi: non-maskab le interrupt writing a zero to this bit has no effect. writing a one to this bit will disable the non-maskable interrupt. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------nmi 76543210 int7 int6 int5 int4 int3 int2 int1 int0
119 32059l?avr32?01/2012 at32uc3b 13.7.15 control register name: ctrl access type: read-only offset: 0x038 reset value: 0x00000000 ?intn: external interrupt n 0: the corresponding external interrupt is disabled. 1: the corresponding external interrupt is enabled. ? nmi: non-maskab le interrupt 0: the non-maskable interrupt is disabled. 1: the non-maskable interrupt is enabled. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------nmi 76543210 int7 int6 int5 int4 int3 int2 int1 int0
120 32059l?avr32?01/2012 at32uc3b 14. flash controller (flashc) rev: 2.1.2.4 14.1 features ? controls flash block with dual read ports allowing staggered reads. ? supports 0 and 1 wait state bus access. ? allows interleaved burst reads for systems with one wait state, outputting one 32-bit word per clock cycle. ? 32-bit hsb interface for reads from flash array and writes to page buffer. ? 32-bit pb interface for issuing commands to and configuration of the controller. ? 16 lock bits, each protecting a region consisting of (total number of pages in the flash block / 16) pages. ? regions can be individually protected or unprotected. ? additional protection of the boot loader pages. ? supports reads and writes of general-purpose nvm bits. ? supports reads and writes of additional nvm pages. ? supports device protection through a security bit. ? dedicated command for chip-erase, first erasing all on-chip volatile me mories before erasing flash and clearing security bit. ? interface to power manager for power-down of flash-blocks in sleep mode. ? 14.2 overview the flash controller (flashc) interfaces a flash block with the 32-bit internal high-speed bus (hsb). performance for uncached systems with high clock-frequency and one wait state is increased by placing words with sequential addre sses in alternating flash subblocks. having one read interface per subblock allows them to be read in parallel. while data from one flash sub- block is being output on the bus, the sequentia l address is being read from the other flash subblock and will be ready in the next clock cycle. the controller also manages the programming, erasing, locking and unlocking sequences with dedicated commands. 14.3 product dependencies 14.3.1 power manager the flashc has two bus clocks connected: one high speed bus clock (clk_flashc_hsb) and one peripheral bus clock (clk_flashc_pb). these clocks are generated by the power manager. both clocks are tu rned on by default, but th e user has to ensure that clk_flashc_hsb is not turned off before readin g the flash or writing the pagebuffer and that clk_flashc_pb is not turned off before acce ssing the flashc confi guration and control registers. 14.3.2 interrupt controller the flashc interrupt lines are connected to internal sources of the interrupt controller. using flashc interrupts requires the interrupt controller to be programmed first.
121 32059l?avr32?01/2012 at32uc3b 14.4 functional description 14.4.1 bus interfaces the flashc has two bus interfaces, one hsb interface for reads from the flash array and writes to the page buffer, and one peripheral bu s (pb) interface for writing commands and con- trol to and reading status from the controller. 14.4.2 memory organization to maximize performance for high clock-frequenc y systems, flashc interfaces to a flash block with two read ports. the flash block has several parameters, given by th e design of the flash block. refer to the ?memories? chapter for t he device-specific values of the parameters. ? p pages ( flash_p ) ? w words in each page and in the page buffer ( flash_w ) ? pw words in total ( flash_pw ) ? f general-purpose fuse bits ( flash_f ) ? 1 security fuse bit ?1 user page 14.4.3 user page the user page is an additional page, outside the regular flash array, that can be used to store various data, like calibration data and serial numbers. this page is not erased by regular chip erase. the user page can only be written and erased by proprietary commands. read accesses to the user page is performed just as any other read access to the flash. the address map of the user page is given in figure 14-1 . 14.4.4 read operations the flashc provides two different read modes: ? 0 wait state (0ws) for clock frequencies < (access time of the flash plus the bus delay) ? 1 wait state (1ws) for clock frequencies < (access time of the flash plus the bus delay)/2 higher clock frequencies that would require more wait states are not supported by the flash controller. the programmer can select the wait states require d by writing to the fws field in the flash con- trol register (fcr). it is the responsibility of the programmer to select a number of wait states compatible with the clock frequency and ti ming characteristics of the flash block. in 0ws mode, only one of the two flash read ports is accessed. the other flash read port is idle. in 1ws mode, both flash read ports are active. one read port reading the addressed word, and the other reading the next sequential word. if the clock frequency allows, the user should use 0ws mode , because this gives the lowest power consumption for low-frequency systems as on ly one flash read port is read. using 1ws mode has a power/performance ratio approaching 0ws mode as the clock frequency approaches twice the max frequency of 0ws mode. using two flash read ports use twice the power, but also give twice the performance.
122 32059l?avr32?01/2012 at32uc3b the flash controller supports flash blocks with up to 2^21 word addresses, as displayed in figure 14-1 . reading the memory space between address pw and 2^21-1 returns an undefined result. the user page is permanently mapped to word address 2^21. figure 14-1. memory map for the flash memories 14.4.5 quick page read a dedicated command, quick page read (qpr), is provided to read all words in an addressed page. all bits in all words in this page are and?e d together, returning a 1-bi t result. this result is placed in the quick page read result (qprr) bi t in flash status register (fsr). the qpr command is useful to check that a page is in an erased state. the qpr instruction is much faster than performing the erased-page check using a regular software subroutine. 14.4.6 write page buffer operations the internal memory area reserved for the emb edded flash can also be written through a write- only page buffer. the page buffer is addressed only by the address bits required to address w words (since the page buffer is word addressable) and thus wrap around within the internal memory area address space and appear to be repeated within it. when writing to the page buffer, the pagen field in the flash command register ( fcmd) is updated with the page number corresponding to page address of the latest word written into the page buffer. table 14-1. user page addresses memory type start addr ess, byte sized size main array 0 pw words = 4 pw bytes user 2^23 = 8388608 w words = 4w bytes 0 pw-1 pw 2^21+128 unused flash data array unused user page flash with extra page 2^21 all addresses are word addresses
123 32059l?avr32?01/2012 at32uc3b the page buffer is also used for writes to the user page. write operations can be prevented by programming the memory protection unit of the cpu. writing 8-bit and 16-bit data to the page buffer is not allowed and may lead to unpredictable data corruption. page buffer write operations are performed with 4 wait states. writing to the page buffer can only change page buffer bits from one to zero, i.e. writing 0xaaaaaaaa to a page buffer location that has the value 0x00000000, will not change the page buffer value. the only way to change a bit from zero to one, is to reset the entire page buffer with the clear page buffer command. the page buffer is not automatically reset after a page write. the programmer should do this manually by issuing the clear page buffer fl ash command. this can be done after a page write, or before the page buffer is loaded wit h data to be stored to the flash page. example: writing a word into word address 130 of a flash with 128 words in the page buffer. pagen will be updated with the va lue 1, and the word will be writ ten into word 2 in the page buffer. 14.4.7 writing words to a page that is not completely erased this can be used for eeprom emulation, i.e. writes with granularity of one word instead of an entire page. only words that are in an comp letely erased state (0xffffffff) can be changed. the procedure is as follows: 1. clear page buffer 2. write to the page buffer the result of the logical bitwise and operation between the contents of the flash page and the new data to write. only words th at were in an erased state can be changed from the original page. 3. write page. 14.5 flash commands the flashc offers a command set to manage progr amming of the flash memory, locking and unlocking of regions, and full flash erasing. see chapter 14.8.2 for a co mplete list of commands. to run a command, the field fcmd.cmd has to be written with the command number. as soon as fcmd is written, the frdy bit is automatic ally cleared. once the current command is com- plete, the frdy bit is automatically set. if an interrupt has been enabled by setting the bit frdy in fcr, the interrupt lin e of the flash controller is activated. all flash commands except for quick page read (qpr) will generate an interrupt re quest upon completion if frdy is set. after a command has been written to fcmd, the programming algorithm should wait until the command has been executed before attempting to read instructions or data from the flash or writing to the page buffer, as the flash will be busy. the waiting can be pe rformed either by poll- ing the flash status register (fsr) or by waiting for the flash ready interrupt. the command written to fcmd is initiated on the first clock cycle where the hsb bus interface in flashc is idle. the user must make sure that the access pattern to the flashc hsb interface contains an idle cycle so that the command is allowed to start. make sure that no bus masters such as dma controllers are performing endless burst transf ers from the flash. also , make sure that the cpu does not perform endless burst transfers from flash. this is done by letting the cpu enter sleep mode after writing to fcmd, or by polling fsr for command completion. this polling will result in an access patt ern with idle hsb cycles.
124 32059l?avr32?01/2012 at32uc3b all the commands are protected by the same keywor d, which has to be written in the eight high- est bits of fcmd. writing fcmd with data that does not contain the correct key and/or with an invalid command has no effect on the flash memory ; however, the proge bit is set in fsr. this bit is automatically cleared by a read access to fsr. writing a command to fcmd while another comma nd is being executed has no effect on the flash memory; however, the proge bit is set in fs r. this bit is automatically cleared by a read access to fsr. if the current command writes or erases a page in a locked region, or a page protected by the bootprot fuses, the command has no effect on the flash memory; however, the locke bit is set in fsr . this bit is automatically cleared by a read access to fsr. 14.5.1 write/erase page operation flash technology requires that an erase must be done before programming. the entire flash can be erased by an erase all command. alternativ ely, pages can be individually erased by the erase page command. the user page can be written and erased usin g the mechanisms descr ibed in this chapter. after programming, the page can be locked to pr event miscellaneous writ e or erase sequences. locking is performed on a per-region basis, so locking a region locks all pages inside the region. additional protection is provided for the lowe rmost address space of the flash. this address space is allocated for the boot loader, and is pr otected both by the lock bit(s) corresponding to this address space, and the bootprot[2:0] fuses. data to be written are stored in an internal buffer called page buffer. the page buffer contains w words. the page buffer wraps around within the internal memory area address space and appears to be repeated by the number of pages in it. writing of 8-bit and 16-bit data to the page buffer is not allowed and may lead to unpredictable data corruption. data must be written to the page buffer before the programming command is written to fcmd. the sequence is as follows: ? reset the page buffer with the clear page buffer command. ? fill the page buffer with the desired co ntents, using only 32-bit access. ? programming starts as soon as the programming key and the programming command are written to the flash command register. the fcmd .pagen field must contain the address of the page to write. pagen is automatically updated when writing to the page buffer, but can also be written to directly. the frdy bit in fs r is automatically cleare d when the page write operation starts. ? when programming is completed, the bit frdy in fsr is set. if an interrupt was enabled by setting the bit frdy in fcr, the interr upt line of the flash controller is set. two errors can be detected in fsr after a programming sequence: ? programming error: a bad keyword and/or an invalid command have been written in fcmd. ? lock error: the page to be programmed belongs to a locked region. a command must be executed to unlock the corresponding region before programming can start. 14.5.2 erase all operation the entire memory is erased if the erase all co mmand (ea) is written to fcmd. erase all erases all bits in the flash array. the user page is not erased. all flash memory locations, the general- purpose fuse bits, and the security bit are erased (reset to 0xff) after an erase all.
125 32059l?avr32?01/2012 at32uc3b the ea command also ensures that all volatile me mories, such as register file and rams, are erased before the security bit is erased. erase all operation is allowed only if no regi ons are locked, and the bootprot fuses are pro- grammed with a region size of 0. thus, if at le ast one region is locked, the bit locke in fsr is set and the command is cancelled. if the bit locke has been written to 1 in fcr, the interrupt line rises. when the command is comp lete, the bit frdy bit in fsr is se t. if an interrupt has been enabled by setting the bit frdy in fcr, the interrupt line of the flash controller is set. two errors can be detected in fsr after issuing the command: ? programming error: a bad keyword and/or an invalid command have been written in fcmd. ? lock error: at least one lock region to be er ased is protected, or bootprot is different from 0. the erase command has been refused and no page has been erased. a clear lock bit command must be executed previously to unlock the corresponding lock regions. 14.5.3 region lock bits the flash block has p pages, and these pages are grouped into 16 lock regions, each region containing p /16 pages. each region has a dedicated lock bit preventing writing and erasing pages in the region. after production, the device may have some regions locked. these locked regions are reserved for a boot or default applic ation. locked regions can be unlocked to be erased and then programmed with another application or other data. to lock or unlock a region, the commands lock region containing page (lp) and unlock region containing page (up) are provided. writing one of these commands, together with the number of the page whose region should be locked/unlocked, performs the desired operation. one error can be detected in fsr after issuing the command: ? programming error: a bad keyword and/or an invalid command have been written in fcmd. the lock bits are implemented using the lowest 16 general-purpose fuse bits. this means that lock bits can also be set/cleared using the commands for writing/erasing general-purpose fuse bits, see chapter 14.6. the general-purpose bit being in an erased (1) state means that the region is unlocked. the lowermost pages in the flash can additionally be protected by the bootprot fuses, see section 14.6 . 14.6 general-purpose fuse bits each flash block has a number of general-purpos e fuse bits that the application programmer can use freely. the fuse bits can be written and erased using dedicated commands, and read
126 32059l?avr32?01/2012 at32uc3b through a dedicated peripheral bus address. some of the general-purpose fuse bits are reserved for special purposes, and shou ld not be used for other functions.: the bootprot fuses protects the following address space for the boot loader: table 14-2. general-purpose fuses with special functions general- purpose fuse number name usage 15:0 lock region lock bits. 16 epfl external privileged fetch lock. used to prevent the cpu from fetching instructions from external memories when in privileged mode. this bit can only be changed when the security bit is cleared. the address range corresponding to external memories is device-specific, and not known to the flash controller. this fuse bit is simply routed out of the cpu or bus system, the flash controller does not treat this fuse in any special way, except that it can not be altered when the security bit is set. if the security bit is set, only an external jtag chip erase can clear epfl. no internal commands can alter epfl if the security bit is set. when the fuse is erased (i.e. "1"), the cpu can execute instructions fetched from external memories. when the fuse is programmed (i.e. "0"), instructions can not be executed from external memories. 19:17 bootprot used to select one of eight different boot loader sizes. pages included in the bootlegger area can not be erased or programmed except by a jtag chip erase. bootprot can only be changed when the security bit is cleared. if the security bit is set, only an external jtag chip erase can clear bootprot, and thereby allow the pages protected by bootprot to be programmed. no internal commands can alter bootprot or the pages protected by bootprot if the security bit is set. table 14-3. boot loader area specified by bootprot bootprot pages protected by bootprot size of protected memory 7none 0 60-1 1kbyte 50-3 2kbyte 40-7 4kbyte 3 0-15 8kbyte 2 0-31 16kbyte 1 0-63 32kbyte 0 0-127 64kbyte
127 32059l?avr32?01/2012 at32uc3b to erase or write a general-purpose fuse bit, the commands write general-purpose fuse bit (wgpb) and erase general-purpose fuse bit (e gpb) are provided. writing one of these com- mands, together with the number of the fuse to write/erase, performs the desired operation. an entire general-purpose fuse byte can be wr itten at a time by us ing the program gp fuse byte (pgpfb) instruction. a pgpfb to gp fuse byte 2 is not allowed if the flash is locked by the security bit. the pfb command is issued with a parameter in the pagen field: ? pagen[2:0] - byte to write ? pagen[10:3] - fuse value to write all general-purpose fuses can be erased by the erase all general-purpose fuses (eagp) com- mand. an eagp command is not allowed if the flash is lo cked by the security bit. two errors can be detected in fsr after issuing these commands: ? programming error: a bad keyword and/or an invalid command have been written in fcmd. ? lock error: a write or erase of any of the special-function fuse bits in table 14-3 was attempted while the flash is locked by the security bit. the lock bits are implemented using the lowest 16 general-purpose fuse bits. this means that the 16 lowest general-purpose fuse bits can also be written/erased using the commands for locking/unlocking regions, see section 14.5.3 . 14.7 security bit the security bit allows the entire chip to be locked from external jtag or other debug access for code security. the security bit can be written by a dedicated command, set security bit (ssb). once set, the only way to clear the security bit is through the jtag chip erase command. once the security bit is set, the following flash controller commands will be unavailable and return a lock error if attempted: ? write general-purpose fuse bit (w gpb) to bootprot or epfl fuses ? erase general-purpose fuse bit (egpb) to bootprot or epfl fuses ? program general-purpose fuse byte (pgpfb) of fuse byte 2 ? erase all general-pu rpose fuses (eagpf) one error can be detected in fsr after issuing the command: ? programming error: a bad keyword and/or an invalid command have been written in fcmd.
128 32059l?avr32?01/2012 at32uc3b 14.8 user interface (*) the value of the lock bits is dependent of t heir programmed state. all other bits in fsr are 0. all bits in fgpfr and fcfr are dependent on the programmed state of the fuses they map to. any bits in these registers not mapped to a fuse read 0. table 14-4. flashc register memory map offset register name access reset 0x0 flash control register fcr r/w 0x00000000 0x4 flash command register fcmd r/w 0x00000000 0x8 flash status register fsr r/w 0x00000000 (*) 0xc flash general purpose fuse register hi fgpfrhi r na (*) 0x10 flash general purpose fuse register lo fgpfrlo r na (*)
129 32059l?avr32?01/2012 at32uc3b 14.8.1 flash control register name : fcr access type : read/write offset : 0x00 reset value : 0x00000000 ? frdy: flash ready interrupt enable 0: flash ready does not generate an interrupt. 1: flash ready generates an interrupt. ? locke: lock error interrupt enable 0: lock error does not generate an interrupt. 1: lock error generates an interrupt. ? proge: programming e rror interrupt enable 0: programming error does not generate an interrupt. 1: programming error generates an interrupt. ? fws: flash wait state 0: the flash is read with 0 wait states. 1: the flash is read with 1 wait state. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - fws - - proge locke - frdy
130 32059l?avr32?01/2012 at32uc3b 14.8.2 flash command register name : fcmd access type : read/write offset : 0x04 reset value : 0x00000000 fcmd can not be written if the flash is in t he process of performing a flash command. doing so will cause the fcr write to be ignore d, and the proge bit to be set. ? cmd: command this field defines the flash command. issuing any unused command will cause the programming error bit to be set, and the corresponding interrupt to be requested if fcr.proge is set. 31 30 29 28 27 26 25 24 key 23 22 21 20 19 18 17 16 pagen [15:8] 15 14 13 12 11 10 9 8 pagen [7:0] 76543210 -- cmd table 14-5. set of commands command value mnemonic no operation 0 nop write page 1 wp erase page 2 ep clear page buffer 3 cpb lock region containing given page 4 lp unlock region containing given page 5 up erase all 6 ea write general-purpose fuse bit 7 wgpb erase general-purpose fuse bit 8 egpb set security bit 9 ssb program gp fuse byte 10 pgpfb erase all gpfuses 11 eagpf quick page read 12 qpr
131 32059l?avr32?01/2012 at32uc3b ? pagen: page number the pagen field is used to address a page or fuse bit for certain operations. in order to simplify programming, the pagen field is automatically updated every time the page buffer is written to. for every page buffer write, the pagen field is updated with the page number of the address being written to. hardware autom atically masks writes to the pagen field so that only bits representing valid page numbers can be written, all other bits in pagen are always 0. as an example, in a flash with 1024 pages (page 0 - page 1023), bits 15:10 will always be 0. ? key: write protection key this field should be written with the value 0xa5 to enable the co mmand defined by the bits of the register. if the field is wri tten with a different value, the write is not performed and no action is started. this field always reads as 0. write user page 13 wup erase user page 14 eup quick page read user page 15 qprup table 14-6. semantic of pagen field in different commands command pagen description no operation not used write page the number of the page to write clear page buffer not used lock region containing given page page nu mber whose region should be locked unlock region containing given page page number whose region should be unlocked erase all not used write general-purpose fuse bit gpfuse # erase general-purpose fuse bit gpfuse # set security bit not used program gp fuse byte writedata[7:0], byteaddress[2:0] erase all gp fuses not used quick page read page number write user page not used erase user page not used quick page read user page not used table 14-5. set of commands command value mnemonic
132 32059l?avr32?01/2012 at32uc3b 14.8.3 flash status register name : fsr access type : read/write offset : 0x08 reset value : 0x00000000 ? frdy: flash ready status 0: the flash controller is busy and the application must wait before running a new command. 1: the flash controller is ready to run a new command. ? locke: lock error status automatically cleared when fsr is read. 0: no programming of at least one locked lock region has happened since the last read of fsr. 1: programming of at least one locked lock region has happened since the last read of fsr. ? proge: programm ing error status automatically cleared when fsr is read. 0: no invalid commands and no bad keywords were written in fcmd. 1: an invalid command and/or a bad keyword was/were written in fcmd. ? security: security bit status 0: the security bit is inactive. 1: the security bit is active. ? qprr: quick page read result 0: the result is zero, i.e. the page is not erased. 1: the result is one, i.e. the page is erased. 31 30 29 28 27 26 25 24 lock15 lock14 lock13 lock12 lock11 lock10 lock9 lock8 23 22 21 20 19 18 17 16 lock7 lock6 lock5 lock4 lock3 lock2 lock1 lock0 15 14 13 12 11 10 9 8 fsz ----- 76543210 - - qprr security proge locke - frdy
133 32059l?avr32?01/2012 at32uc3b ? fsz: flash size the size of the flash. not all device families will provide all flash sizes indicated in the table. ? lockx: lock region x lock status 0: the corresponding lock region is not locked. 1: the corresponding lock region is locked. table 14-7. flash size fsz flash size 032 kbytes 164 kbytes 2128 kbytes 3256 kbytes 4384 kbytes 5512 kbytes 6768 kbytes 7 1024 kbytes
134 32059l?avr32?01/2012 at32uc3b 14.8.4 flash general purpose fuse register high name : fgpfrhi access type : read offset : 0x0c reset value : n/a this register is only used in systems with more than 32 gp fuses. ? gpfxx: general purpose fuse xx 0: the fuse has a written/programmed state. 1: the fuse has an erased state. 31 30 29 28 27 26 25 24 gpf63 gpf62 gpf61 gpf60 gpf59 gpf58 gpf57 gpf56 23 22 21 20 19 18 17 16 gpf55 gpf54 gpf53 gpf52 gpf51 gpf50 gpf49 gpf48 15 14 13 12 11 10 9 8 gpf47 gpf46 gpf45 gpf44 gpf43 gpf42 gpf41 gpf40 76543210 gpf39 gpf38 gpf37 gpf36 gpf35 gpf34 gpf33 gpf32
135 32059l?avr32?01/2012 at32uc3b 14.8.5 flash general purpose fuse register low name : fgpfrlo access type : read offset : 0x10 reset value : n/a ? gpfxx: general purpose fuse xx 0: the fuse has a written/programmed state. 1: the fuse has an erased state. 31 30 29 28 27 26 25 24 gpf31 gpf30 gpf29 gpf28 gpf27 gpf26 gpf25 gpf24 23 22 21 20 19 18 17 16 gpf23 gpf22 gpf21 gpf20 gpf19 gpf18 gpf17 gpf16 15 14 13 12 11 10 9 8 gpf15 gpf14 gpf13 gpf12 gpf11 gpf10 gpf09 gpf08 76543210 gpf07 gpf06 gpf05 gpf04 gpf03 gpf02 gpf01 gpf00
136 32059l?avr32?01/2012 at32uc3b 14.9 fuses settings the flash block contains a number of general pu rpose fuses. some of these fuses have defined meanings outside the flash controller and are described in this section. the general purpose fuses are erase by a jtag chip erase. 14.9.1 flash general purpose fuse register low (fgpfrlo) boden: brown out detector enable bodhyst: brown out de tector hysteresis 0: the brown out detector hysteresis is disabled 1: the brown out detector hysteresis is enabled bodlevel: brown out detector trigger level this controls the voltage trigger level for the brown out detector. refer to electrical characteris- tics section. if the bodlevel is set higher than vddcore and enabled byt fuse s, the part will be in constant reset. to recover from this situ ation, apply an external voltage on vddcore that is higher than the bod level and disable the bod. lock, epfl, bootprot these are flash controller fuses and are described in the flashc section. as no external memories can be connected to at32uc3b the epfl bit has no effect. 31 30 29 28 27 26 25 24 gpf31 gpf30 gpf29 boden bodhyst bodlevel[5:4] 23 22 21 20 19 18 17 16 bodlevel[3:0] bootprot epfl 15 14 13 12 11 10 9 8 lock[15:8] 76543210 lock[7:0] boden description 0x0 bod disabled 0x1 bod enabled, bod reset enabled 0x2 bod enabled, bod reset disabled 0x3 bod disabled
137 32059l?avr32?01/2012 at32uc3b 14.9.2 default fuse value the devices are shipped with the fgpfrlo register value: 0xfc07ffff: ? gpf31 fuse set to 1b. this fuse is used by the pre-programmed usb bootloader. ? gpf30 fuse set to 1b. this fuse is used by the pre-programmed usb bootloader. ? gpf29 fuse set to 1b. this fuse is used by the pre-programmed usb bootloader. ? boden fuses set to 11b. bod is disabled. ? bodhyst fuse set to 1b. the bod hysteresis is enabled. ? bodlevel fuses set to 000000b . this is the minimum voltag e trigger level. bod will never trigger as this level is below the por level. ? bootprot fuses set to 011b. the bootloader protected size is 8 ko. ? epfl fuse set to 1b. external privileged fetch is not locked. ? lock fuses set to 1111111111111111b. no region locked. see also the at32uc3b bootloader user guide document. after the jtag chip erase command, the fgpfrlo register value is 0xffffffff. 14.10 bootloader configuration the bootloader uses one word in the flash user page to store its configuration. this configura- tion word is located at address 0x808001f c and its default value is 0x929e0d6b. refer to the bootloader documentation for more information. 14.11 serial number each device has a unique 120 bits serial number readable from address 0x80800204 to 0x80800212. 14.12 module configuration table 14-8. flash memory parameters part number flash size ( flash_pw ) number of pages ( flash_p ) page size ( flash_w ) general purpose fuse bits ( flash_l ) at32uc3b0512 512 kbytes 1024 128 words 32 fuses at32uc3b1512 512 kbytes 1024 128 words 32 fuses at32uc3b0256 256 kbytes 512 128 words 32 fuses at32uc3b1256 256 kbytes 512 128 words 32 fuses at32uc3b0128 128 kbytes 256 128 words 32 fuses at32uc3b1128 128 kbytes 256 128 words 32 fuses at32uc3b064 64 kbytes 128 128 words 32 fuses at32uc3b164 64 kbytes 128 128 words 32 fuses
138 32059l?avr32?01/2012 at32uc3b 15. hsb bus matrix (hmatrix) rev: 2.3.0.2 15.1 features ? user interface on peripheral bus ? configurable number of masters (up to sixteen) ? configurable number of slaves (up to sixteen) ? one decoder for each master ? ? programmable arbitration for each slave ? round-robin ? fixed priority ? programmable default master for each slave ? no default master ? last accessed default master ? fixed default master ? one cycle latency for the first access of a burst ? zero cycle latency for default master ? one special function register for each slave (not dedicated) 15.2 overview the bus matrix implements a multi-layer bus structure, that enables parallel access paths between multiple high speed bus (hsb) masters an d slaves in a system, thus increasing the overall bandwidth. the bus matrix interconnects up to 16 hsb masters to up to 16 hsb slaves. the normal latency to connect a master to a slave is one cycle except fo r the default master of the accessed slave which is connected directly (zero cycle latency). the bus matrix provides 16 special function registers (sfr) that allow the bus matrix to support application specific features. 15.3 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 15.3.1 clocks the clock for the hmatrix bus interface (clk_h matrix) is generated by the power manager. this clock is enabled at reset, and can be disabled in the power manager. it is recommended to disable the hmatrix before disabling the clock, to avoid freezing the hmatrix in an undefined state. 15.4 functional description 15.4.1 special bus granting mechanism the bus matrix provides some speculative bus gr anting techniques in order to anticipate access requests from some masters. this mechanism reduc es latency at first access of a burst or single transfer. this bus granting mechanism sets a different default master for every slave.
139 32059l?avr32?01/2012 at32uc3b at the end of the current access , if no other request is pendi ng, the slave remains connected to its associated default master. a slave can be associat ed with three kinds of default masters: no default master, last access ma ster and fixed default master. 15.4.1.1 no default master at the end of the current access, if no other request is pending, the slave is disconnected from all masters. no default ma ster suits low-power mode. 15.4.1.2 last access master at the end of the current access , if no other request is pendi ng, the slave remains connected to the last master that performed an access request. 15.4.1.3 fixed default master at the end of the current access, if no other r equest is pending, the slav e connects to its fixed default master. unlike last access master, th e fixed master does not change unless the user modifies it by a software action (fie ld fixed_defmstr of the related scfg). to change from one kind of default master to ano ther, the bus matrix user interface provides the slave configuration registers, one for each slave, that set a default master for each slave. the slave configuration register contains two fields: defmstr_type and fixed_defmstr. the 2-bit defmstr_type field selects the default mast er type (no default, last access master, fixed default master), whereas the 4-bit fixed_defmstr field selects a fixed default master pro- vided that defmstr_type is set to fixed defaul t master. please refer to the bus matrix user interface description. 15.4.2 arbitration the bus matrix provides an arbitration mechanism that reduces latency when conflict cases occur, i.e. when two or more masters try to ac cess the same slave at the same time. one arbiter per hsb slave is provided, thus ar bitrating each slave differently. the bus matrix provides the user with the possib ility of choosing between 2 arbitration types for each slave: 1. round-robin arbitration (default) 2. fixed priority arbitration this choice is made via the field arbt of the slave configuration registers (scfg). each algorithm may be complemented by selecting a default master configuration for each slave. when a re-arbitration must be do ne, specific conditions apply. see section 15.4.2.1 ?arbitration rules? on page 139 . 15.4.2.1 arbitration rules each arbiter has the ability to arbitrate between two or more different master requests. in order to avoid burst breaking and also to provide the maximum throughput for slave interfaces, arbitra- tion may only take place during the following cycles: 1. idle cycles: when a slave is not connected to any master or is connected to a master which is not currently accessing it. 2. single cycles: when a slave is currently doing a single access.
140 32059l?avr32?01/2012 at32uc3b 3. end of burst cycles: when the current cycle is the last cycle of a burst transfer. for defined length burst, predicted end of burst ma tches the size of the transfer but is man- aged differently for undefined length burst. 4. slot cycle limit: when the slot cycle counter has reached th e limit value indicating that the current master access is too long and must be broken. ? undefined length burst arbitration in order to avoid long slave handling during unde fined length bursts (incr), the bus matrix pro- vides specific logic in order to re-arbitrate before the end of the incr transfer. a predicted end of burst is used as a defined length burst trans fer and can be selected from among the following five possibilities: 1. infinite: no predicted end of burst is g enerated and therefore incr burst transfer will never be broken. 2. one beat bursts: predicted end of burst is generated at each single transfer inside the incp transfer. 3. four beat bursts: predicted end of burst is generated at the end of each four beat boundary inside incr transfer. 4. eight beat bursts: predicted end of burst is generated at the end of each eight beat boundary inside incr transfer. 5. sixteen beat bursts: predicted end of burst is generated at the end of each sixteen beat boundary inside incr transfer. this selection can be done through the field ulbt of the master configuration registers (mcfg). ? slot cycle limit arbitration the bus matrix contains specific logic to break long accesses, such as very long bursts on a very slow slave (e.g., an external low speed me mory). at the beginning of the burst access, a counter is loaded with the value previously written in the slot_cycle field of the related slave configuration register (scfg) and decreased at each clock cycle. when the counter reaches zero, the arbiter has the ability to re-arbitrate at the end of the current byte, half word or word transfer. 15.4.2.2 round-robin arbitration this algorithm allows the bus matrix arbiters to dispatch the requests from different masters to the same slave in a round-robin manner. if two or more master requests ar ise at the same time, the master with the lowest number is first serviced, then the others are serviced in a round-robin manner. there are three round-robin algorithms implemented: 1. round-robin arbitratio n without default master 2. round-robin arbitration with last default master 3. round-robin arbitration with fixed default master ? round-robin arbitration without default master this is the main algorithm used by bus matrix arbiters. it allows the bus matrix to dispatch requests from different masters to the same slave in a pure round-robin manner. at the end of
141 32059l?avr32?01/2012 at32uc3b the current access, if no other request is pendin g, the slave is disconnected from all masters. this configuration incurs one la tency cycle for the first access of a burst. arbitration without default master can be used for mast ers that perform significant bursts. ? round-robin arbitration with last default master this is a biased round-robin algorithm used by bus matrix arbiters. it allows the bus matrix to remove the one latency cycle for th e last master that accessed the slave. in fact, at the end of the current transfer, if no other master request is pending, the slave remains connected to the last master that perfo rmed the access. other n on privileged masters still get one latency cycle if they want to access the same sl ave. this technique can be used for masters that mainly perform single accesses. ? round-robin arbitration with fixed default master this is another biased round-robin algorithm. it a llows the bus matrix arbi ters to remove the one latency cycle for the fixed default master per slav e. at the end of the current access, the slave remains connected to its fixed default master. ev ery request attempted by this fixed default mas- ter will not cause any latency whereas other non privileged masters w ill still get one latency cycle. this technique can be used for masters that mainly perform single accesses. 15.4.2.3 fixed priority arbitration this algorithm allows the bus matrix arbiters to dispatch the requests from different masters to the same slave by using the fixed priority defined by the user. if two or more master requests are active at the same time, the master with the highest priority number is serviced first. if two or more master requests with the same priority are active at the same time, the master with the highest number is serviced first. for each slave, the priority of each master may be defined through the priority registers for slaves (pras and prbs). 15.4.3 slave and master assignation the index number assigned to bus matrix slav es and masters are described in memories chapter.
142 32059l?avr32?01/2012 at32uc3b 15.5 user interface table 15-1. hmatrix register memory map offset register name access reset value 0x0000 master configuration register 0 mcfg0 read/write 0x00000002 0x0004 master configuration register 1 mcfg1 read/write 0x00000002 0x0008 master configuration register 2 mcfg2 read/write 0x00000002 0x000c master configuration register 3 mcfg3 read/write 0x00000002 0x0010 master configuration register 4 mcfg4 read/write 0x00000002 0x0014 master configuration register 5 mcfg5 read/write 0x00000002 0x0018 master configuration register 6 mcfg6 read/write 0x00000002 0x001c master configuration register 7 mcfg7 read/write 0x00000002 0x0020 master configuration register 8 mcfg8 read/write 0x00000002 0x0024 master configuration register 9 mcfg9 read/write 0x00000002 0x0028 master configuration register 10 mcfg10 read/write 0x00000002 0x002c master configuration register 11 mcfg11 read/write 0x00000002 0x0030 master configuration register 12 mcfg12 read/write 0x00000002 0x0034 master configuration register 13 mcfg13 read/write 0x00000002 0x0038 master configuration register 14 mcfg14 read/write 0x00000002 0x003c master configuration register 15 mcfg15 read/write 0x00000002 0x0040 slave configuration register 0 scfg0 read/write 0x00000010 0x0044 slave configuration register 1 scfg1 read/write 0x00000010 0x0048 slave configuration register 2 scfg2 read/write 0x00000010 0x004c slave configuration register 3 scfg3 read/write 0x00000010 0x0050 slave configuration register 4 scfg4 read/write 0x00000010 0x0054 slave configuration register 5 scfg5 read/write 0x00000010 0x0058 slave configuration register 6 scfg6 read/write 0x00000010 0x005c slave configuration register 7 scfg7 read/write 0x00000010 0x0060 slave configuration register 8 scfg8 read/write 0x00000010 0x0064 slave configuration register 9 scfg9 read/write 0x00000010 0x0068 slave configuration register 10 scfg10 read/write 0x00000010 0x006c slave configuration register 11 scfg11 read/write 0x00000010 0x0070 slave configuration register 12 scfg12 read/write 0x00000010 0x0074 slave configuration register 13 scfg13 read/write 0x00000010 0x0078 slave configuration register 14 scfg14 read/write 0x00000010 0x007c slave configuration register 15 scfg15 read/write 0x00000010 0x0080 priority register a for slave 0 pras0 read/write 0x00000000 0x0084 priority register b for slave 0 prbs0 read/write 0x00000000 0x0088 priority register a for slave 1 pras1 read/write 0x00000000
143 32059l?avr32?01/2012 at32uc3b 0x008c priority register b for slave 1 prbs1 read/write 0x00000000 0x0090 priority register a for slave 2 pras2 read/write 0x00000000 0x0094 priority register b for slave 2 prbs2 read/write 0x00000000 0x0098 priority register a for slave 3 pras3 read/write 0x00000000 0x009c priority register b for slave 3 prbs3 read/write 0x00000000 0x00a0 priority register a for slave 4 pras4 read/write 0x00000000 0x00a4 priority register b for slave 4 prbs4 read/write 0x00000000 0x00a8 priority register a for slave 5 pras5 read/write 0x00000000 0x00ac priority register b for slave 5 prbs5 read/write 0x00000000 0x00b0 priority register a for slave 6 pras6 read/write 0x00000000 0x00b4 priority register b for slave 6 prbs6 read/write 0x00000000 0x00b8 priority register a for slave 7 pras7 read/write 0x00000000 0x00bc priority register b for slave 7 prbs7 read/write 0x00000000 0x00c0 priority register a for slave 8 pras8 read/write 0x00000000 0x00c4 priority register b for slave 8 prbs8 read/write 0x00000000 0x00c8 priority register a for slave 9 pras9 read/write 0x00000000 0x00cc priority register b for slave 9 prbs9 read/write 0x00000000 0x00d0 priority register a for slave 10 pras10 read/write 0x00000000 0x00d4 priority register b for slave 10 prbs10 read/write 0x00000000 0x00d8 priority register a for slave 11 pras11 read/write 0x00000000 0x00dc priority register b for slave 11 prbs11 read/write 0x00000000 0x00e0 priority register a for slave 12 pras12 read/write 0x00000000 0x00e4 priority register b for slave 12 prbs12 read/write 0x00000000 0x00e8 priority register a for slave 13 pras13 read/write 0x00000000 0x00ec priority register b for slave 13 prbs13 read/write 0x00000000 0x00f0 priority register a for slave 14 pras14 read/write 0x00000000 0x00f4 priority register b for slave 14 prbs14 read/write 0x00000000 0x00f8 priority register a for slave 15 pras15 read/write 0x00000000 0x00fc priority register b for slave 15 prbs15 read/write 0x00000000 0x0110 special function register 0 sfr0 read/write ? 0x0114 special function register 1 sfr1 read/write ? 0x0118 special function register 2 sfr2 read/write ? 0x011c special function register 3 sfr3 read/write ? 0x0120 special function register 4 sfr4 read/write ? 0x0124 special function register 5 sfr5 read/write ? 0x0128 special function register 6 sfr6 read/write ? table 15-1. hmatrix register memory map (continued) offset register name access reset value
144 32059l?avr32?01/2012 at32uc3b 0x012c special function register 7 sfr7 read/write ? 0x0130 special function register 8 sfr8 read/write ? 0x0134 special function register 9 sfr9 read/write ? 0x0138 special function register 10 sfr10 read/write ? 0x013c special function register 11 sfr11 read/write ? 0x0140 special function register 12 sfr12 read/write ? 0x0144 special function register 13 sfr13 read/write ? 0x0148 special function register 14 sfr14 read/write ? 0x014c special function register 15 sfr15 read/write ? table 15-1. hmatrix register memory map (continued) offset register name access reset value
145 32059l?avr32?01/2012 at32uc3b 15.5.1 master configuration registers name: mcfg0...mcfg15 access type: read/write offset: 0x00 - 0x3c reset value: 0x00000002 ? ulbt: undefined length burst type 0: infinite length burst no predicted end of burst is generated and therefore incr bursts coming from this master cannot be broken. 1: single access the undefined length burst is treated as a succession of single accesses, allowing re-arbitration at each beat of the incr burs t. 2: four beat burst the undefined length burst is split into a four-beat burst, allowing re-arbitration at each four-beat burst end. 3: eight beat burst the undefined length burst is split into an eight-beat burst, allowing re-arbitration at each eight-beat burst end. 4: sixteen beat burst the undefined length burst is split into a sixteen-beat burst, allowing re-arbitration at each sixteen-beat burst end. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ????? ulbt
146 32059l?avr32?01/2012 at32uc3b 15.5.2 slave confi guration registers name: scfg0...scfg15 access type: read/write offset: 0x40 - 0x7c reset value: 0x00000010 ? arbt: arbitration type 0: round-robin arbitration 1: fixed priority arbitration ? fixed_defmstr: fixed default master this is the number of t he default master for this slave. only used if defm str_type is 2. specifying the number of a master which is not connected to the selected slave is equivalent to setting defmstr_type to 0. the size of this field depends on the number of ma sters. this size is log2(number of masters). ? defmstr_type: default master type 0: no default master at the end of the current slave access, if no other master request is pending, the slave is disconnected from all masters. this results in a one cycle latency for the first access of a burst transfer or for a single access. 1: last default master at the end of the current slave access, if no other master r equest is pending, the slave stays connected to the last master having accessed it. this results in not having one cycle latency when the last master tries to access the slave again. 2: fixed default master at the end of the current slave access, if no other master request is pending, the slave connects to the fixed master the numbe r that has been written in the fixed_defmstr field. this results in not having one cycle latency when the fixed master tries to access the slave again. ? slot_cycle: maximum number of allowed cycles for a burst when the slot_cycle limit is reached for a burst, it may be broken by another master trying to access this slave. this limit has been placed to avoid locking a ve ry slow slave when very long bursts are used. this limit must not be very small. unreasonably small values br eak every burst and the bus matrix arbitrates without performing any data transfer. 16 cycles is a reasonable value for slot_cycle. 31 30 29 28 27 26 25 24 ???????arbt 23 22 21 20 19 18 17 16 ? ? fixed_defmstr defmstr_type 15 14 13 12 11 10 9 8 ???????? 76543210 slot_cycle
147 32059l?avr32?01/2012 at32uc3b 15.5.3 priority registers a for slaves name: pras0...pras15 access type: read/write offset: - reset value: 0x00000000 ? mxpr: master x priority fixed priority of master x for accessing the selected slave. the higher the number, the higher the priority. 31 30 29 28 27 26 25 24 ?? m7pr ?? m6pr 23 22 21 20 19 18 17 16 ?? m5pr ?? m4pr 15 14 13 12 11 10 9 8 ?? m3pr ?? m2pr 76543210 ?? m1pr ?? m0pr
148 32059l?avr32?01/2012 at32uc3b 15.5.4 priority registers b for slaves name: prbs0...prbs15 access type: read/write offset: - reset value: 0x00000000 ? mxpr: master x priority fixed priority of master x for accessing the selected slave. the higher the number, the higher the priority. 31 30 29 28 27 26 25 24 ? ? m15pr ? ? m14pr 23 22 21 20 19 18 17 16 ? ? m13pr ? ? m12pr 15 14 13 12 11 10 9 8 ? ? m11pr ? ? m10pr 76543210 ?? m9pr ?? m8pr
149 32059l?avr32?01/2012 at32uc3b 15.5.5 special function registers name: sfr0...sfr15 access type: read/write offset: 0x110 - 0x115 reset value: - ? sfr: special function register fields those registers are not a hmatrix specific register. the field of those will be defined where they are used. 31 30 29 28 27 26 25 24 sfr 23 22 21 20 19 18 17 16 sfr 15 14 13 12 11 10 9 8 sfr 76543210 sfr
150 32059l?avr32?01/2012 at32uc3b 15.6 bus matrix connections accesses to unused areas returns an error re sult to the master requesting such an access. the bus matrix has the several masters and slaves. each master has its own bus and its own decoder, thus allowing a different memory mapp ing per master. the master number in the table below can be used to index the hmatrix control registers. for example, hmatrix mcfg0 register is associated with th e cpu data master interface. each slave has its own arbiter, thus allowing a different arbitration pe r slave. the slave number in the table below can be used to index the hm atrix control registers. for example, scfg3 is associated with the intern al sram slave interface. table 15-2. high speed bus masters master 0 cpu data master 1 cpu instruction master 2 cpu sab master 3 pdca master 4 usbb dma table 15-3. high speed bus slaves slave 0 internal flash slave 1 hsb-pb bridge a slave 2 hsb-pb bridge b slave 3 internal sram slave 4 usbb dpram
151 32059l?avr32?01/2012 at32uc3b figure 15-1. hmatrix master / slave connections cpu data 0 cpu instruction 1 cpu sab 2 pdca 3 usbb dma 4 internal flash 0 hsb-pb bridge a 1 hsb-pb bridge b 2 internal sram 3 usbb dpram 4 hmatrix slaves hmatrix masters
152 32059l?avr32?01/2012 at32uc3b 16. peripheral dma controller (pdca) rev: 1.0.2.1 16.1 features ? multiple channels ? generates transfers between memories and peripherals such as usart and spi ? two address pointers/counters per channel allowing double buffering 16.2 overview the peripheral dma controller (pdca) transfers data between on-chip peripheral modules such as usart, spi and memories (t hose memories may be on- and off-chip memories). using the pdca avoids cpu intervention for data transfer s, improving the performance of the microcon- troller. the pdca can transfer data from memory to a peripheral or from a peripheral to memory. the pdca consists of multiple dma channels. each channel has: ? a peripheral select register ? a 32-bit memory pointer ? a 16-bit transfer counter ? a 32-bit memory pointer reload value ? a 16-bit transfer counter reload value the pdca communicates with the peripheral modul es over a set of handshake interfaces. the peripheral signals the pdca when it is ready to receive or transmit data. the pdca acknowl- edges the request when the transmission has started. when a transmit buffer is empty or a receive bu ffer is full, an optional interrupt request can be generated.
153 32059l?avr32?01/2012 at32uc3b 16.3 block diagram figure 16-1. pdca block diagram 16.4 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 16.4.1 power management if the cpu enters a sleep mode that disables the pdca clocks, the pdca will stop functioning and resume operation after the system wakes up from sleep mode. 16.4.2 clocks the pdca has two bus clocks connected: one high speed bus clock (clk_pdca_hsb) and one peripheral bus clock (clk_pdca_pb). thes e clocks are generated by the power man- ager. both clocks are enabled at reset, and can be disabled in the power manager. it is recommended to disable the pdca before disabling the clocks, to avoid freezing the pdca in an undefined state. 16.4.3 interrupts the pdca interrupt request lines are connected to the interrupt cont roller. using the pdca interrupts requires the interrupt controller to be programmed first. hsb to pb bridge peripheral dma controller (pdca) peripheral 0 high speed bus matrix handshake interfaces peripheral bus irq hsb hsb interrupt controller peripheral 1 peripheral 2 peripheral (n-1) ... memory hsb
154 32059l?avr32?01/2012 at32uc3b 16.5 functional description 16.5.1 basic operation the pdca consists of multiple independent pdca channels, each capable of handling dma requests in parallel. each pdca channels contains a set of configuration registers which must be configured to start a dma transfer. in this section the steps necessary to configure one pdca channel is outlined. the peripheral to transfer data to or from must be configured correctly in the peripheral select register (psr). this is performed by writing the peripheral identity (pid) value for the corre- sponding peripheral to the pid field in the ps r register. the pid also encodes the transfer direction, i.e. memory to peripheral or peripheral to memory. see section 16.5.5 . the transfer size must be written to the transfer size field in the mode register (mr.size). the size must match the data size produced or consumed by the se lected peripheral. see section 16.5.6 . the memory address to tr ansfer to or from, depending on the psr, must be written to the mem- ory address register (mar). for each transfer the memory address is increased by either a one, two or four, depending on the size set in mr. see section 16.5.2 . the number of data items to transfer is written to the tcr register. if the pdca channel is enabled, a transfer will start imm ediately after writing a non-zero value to tc r or the reload ver- sion of tcr, tcrr. after each transfer the tcr value is decreased by one. both mar and tcr can be read while the pdca channel is active to monitor the dma progress. see section 16.5.3 . the channel must be enabled for a transfer to start. a channel is enable by writing a one to the en bit in the control register (cr). 16.5.2 memory pointer each channel has a 32-bit memory address regi ster (mar). this register holds the memory address for the next transfer to be performed. the register is automatically updated after each transfer. the address will be increa sed by either one, two or four depending on the size of the dma transfer (byte, halfword or word). the ma r can be read at any time during transfer. 16.5.3 transfer counter each channel has a 16-bit transfer counter register (tcr). this register must be written with the number of transfers to be performed. the tcr register should cont ain the number of data items to be transferred independently of the trans fer size. the tcr can be read at any time dur- ing transfer to see the number of remaining transfers. 16.5.4 reload registers both the mar and the tcr have a reload regist er, respectively memory address reload regis- ter (marr) and transfer counter reload register (tcrr). these registers provide the possibility for the pdca to work on two memory buffer s for each channel. when one buffer has completed, mar and tcr will be re loaded with the values in marr and tcrr. the reload logic is always enabled and will trigger if the tcr r eaches zero while tcrr holds a non-zero value. after reload, the marr and tcrr registers are cleared. if tcr is zero when writing to tcrr, the tcr and mar are automatically updated with the value written in tcrr and marr.
155 32059l?avr32?01/2012 at32uc3b 16.5.5 peripher al selection the peripheral select register (psr) decides which peripheral should be connected to the pdca channel. a peripheral is se lected by writing the correspondi ng peripheral identity (pid) to the pid field in the psr register. writing the pid will both select the direction of the transfer (memory to peripheral or peripheral to memory ), which handshake interface to use, and the address of the peripheral holding register. refer to the peripheral identity (pid) table in the mod- ule configuration section for the peripheral pid values. 16.5.6 transfer size the transfer size can be set individually for each channel to be either byte, halfword or word (8- bit, 16-bit or 32-bit respectively). transfer size is set by writing the desired value to the transfer size field in the mode register (mr.size). when the pdca moves data between peripherals and memory, data is automatically sized and aligned. when memory is accessed, the size sp ecified in mr.size and system alignment is used. when a peripheral register is accessed t he data to be transferred is converted to a word where bit n in the data corresponds to bit n in the peripheral register. if the transfer size is byte or halfword, bits greater than 8 and16 respectively are set to zero. refer to the module configuratio n section for information regarding what peripheral registers are used for the different peripherals and then to the peripheral specific chapter for information about the size option availabl e for the different registers. 16.5.7 enabling and disabling each dma channel is enabled by writing a one to the transfer enable bit in the control register (cr.ten) and disabled by writing a one to the transfer disable bit (cr. tdis). the current sta- tus can be read from the status register (sr). while the pdca channel is enabled all dma re quest will be handled as long the tcr and tcrr is not zero. 16.5.8 interrupts interrupts can be enabled by writing a one to the corresponding bit in the interrupt enable regis- ter (ier) and disabled by writing a one to the corresponding bit in the interrupt disable register (idr). the interrupt mask register (imr) can be read to see whether an interrupt is enabled or not. the current status of an interrupt source can be read through the interrupt status register (isr). the pdca has three interrupt sources: ? reload counter zero - the tcrr register is zero. ? transfer finished - both the tcr and tcrr registers are zero. ? transfer error - an error has occurred in accessing memory. 16.5.9 priority if more than one pdca channel is requesting tran sfer at a given time, the pdca channels are prioritized by their channel number. channels wi th lower numbers have priority over channels with higher numbers, giving channel zero the highest priority. 16.5.10 error handling if the memory address register (mar) is set to point to an invalid location in memory, an error will occur when the pdca tries to perform a tr ansfer. when an error occurs, the transfer error
156 32059l?avr32?01/2012 at32uc3b bit in the interrup t status register (isr.terr) will be se t and the dma channel that caused the error will be stopped. in order to restart the channel, the user must program the memory address register to a valid address and then writ e a one to the error clear bit in the control register (cr.eclr). if the transfer error interrupt is enabled , an interrupt request will be gener- ated when a transfer error occurs.
157 32059l?avr32?01/2012 at32uc3b 16.6 user interface 16.6.1 memory map overview the channels are mapped as shown in table 16-1 . each channel has a set of configuration reg- isters, shown in table 16-2 , where n is the channel number. 16.6.2 channel memory map note: 1. the reset values are device specific. please refer to the module configuration section at the end of this chapter. note: 1. the reset values are device specific. please refer to the module configuration section at the end of this chapter. table 16-1. pdca register memory map address range contents 0x000 - 0x03f dma channel 0 configuration registers 0x040 - 0x07f dma channel 1 configuration registers ... ... (0x000 - 0x03f)+m*0x040 dma channel m configuration registers table 16-2. pdca channel configuration registers offset register register name access reset 0x000 + n*0x040 memory address register mar read/write 0x00000000 0x004 + n*0x040 peripheral select register psr read/write - (1) 0x008 + n*0x040 transfer counter register tcr read/write 0x00000000 0x00c + n*0x040 memory address reload register marr read/write 0x00000000 0x010 + n*0x040 transfer counter reload register tcrr read/write 0x00000000 0x014 + n*0x040 control register cr write-only 0x00000000 0x018 + n*0x040 mode register mr read/write 0x00000000 0x01c + n*0x040 status register sr read-only 0x00000000 0x020 + n*0x040 interrupt enable register ier write-only 0x00000000 0x024 + n*0x040 interrupt disable register idr write-only 0x00000000 0x028 + n*0x040 interrupt mask register imr read-only 0x00000000 0x02c + n*0x040 interrupt status register isr read-only 0x00000000
158 32059l?avr32?01/2012 at32uc3b 16.6.3 memory address register name: mar access type: read/write offset: 0x000 + n*0x040 reset value: 0x00000000 ? maddr: memory address address of memory buffer. maddr should be programmed to point to the start of the memory buffer when configuring the pdca. during transfer, maddr will point to the next memory location to be read/written. 31 30 29 28 27 26 25 24 maddr[31:24] 23 22 21 20 19 18 17 16 maddr[23:16] 15 14 13 12 11 10 9 8 maddr[15:8] 76543210 maddr[7:0]
159 32059l?avr32?01/2012 at32uc3b 16.6.4 peripheral select register name: psr access type: read/write offset: 0x004 + n*0x040 reset value: - ?pid: peripher al identifier the peripheral identifier selects which peripheral should be connec ted to the dma channel. writing a pid will select both which handshake interface to use, the direction of the transfer and also the address of the receive/transfer holding register for the peripheral. see the module configuration section of pdca for details. the width of the pid field is device specific and dependent on the number of peripheral modules in the device. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 pid
160 32059l?avr32?01/2012 at32uc3b 16.6.5 transfer counter register name: tcr access type: read/write offset: 0x008 + n*0x040 reset value: 0x00000000 ? tcv: transfer counter value number of data items to be transferred by the pdca. tcv must be programmed with the total number of transfers to be made. during transfer, tcv contains the number of remaining transfers to be done. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 tcv[15:8] 76543210 tcv[7:0]
161 32059l?avr32?01/2012 at32uc3b 16.6.6 memory address reload register name: marr access type: read/write offset: 0x00c + n*0x040 reset value: 0x00000000 ? marv: memory address reload value reload value for the mar register. this value will be loaded into mar when tcr reaches zero if the tcrr register has a non- zero value. 31 30 29 28 27 26 25 24 marv[31:24] 23 22 21 20 19 18 17 16 marv[23:16] 15 14 13 12 11 10 9 8 marv[15:8] 76543210 marv[7:0]
162 32059l?avr32?01/2012 at32uc3b 16.6.7 transfer counter reload register name: tcrr access type: read/write offset: 0x010 + n*0x040 reset value: 0x00000000 ? tcrv: transfer counter reload value reload value for the tcr register. when tcr reaches zero, it will be reloaded with tcrv if tcrv has a positive value. if tcrv is zero, no more transfers will be performed for the cha nnel. when tcr is reloaded, the tcrr register is cleared. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 tcrv[15:8] 76543210 tcrv[7:0]
163 32059l?avr32?01/2012 at32uc3b 16.6.8 control register name: cr access type: write-only offset: 0x014 + n*0x040 reset value: 0x00000000 ? eclr: transfer error clear writing a zero to this bit has no effect. writing a one to this bit will clear the transfer error bit in the status register (sr.terr). clearing the sr.terr bit will all ow the channel to transmit data. the memory address must first be set to point to a valid location. ? tdis: transfer disable writing a zero to this bit has no effect. writing a one to this bit will disable transfer for the dma channel. ? ten: transfer enable writing a zero to this bit has no effect. writing a one to this bit will enable transfer for the dma channel. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------eclr 76543210 ------tdisten
164 32059l?avr32?01/2012 at32uc3b 16.6.9 mode register name: mr access type: read/write offset: 0x018 + n*0x040 reset value: 0x00000000 ? size: size of transfer 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 ------ size table 16-3. size of transfer size size of transfer 0byte 1halfword 2word 3 reserved
165 32059l?avr32?01/2012 at32uc3b 16.6.10 status register name: sr access type: read-only offset: 0x01c + n*0x040 reset value: 0x00000000 ? ten: transfer enabled this bit is cleared when the tdis bit in cr is written to one. this bit is set when the ten bit in cr is written to one. 0: transfer is disabled for the dma channel. 1: transfer is enabled for the dma channel. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------ten
166 32059l?avr32?01/2012 at32uc3b 16.6.11 interrupt enable register name: ier access type: write-only offset: 0x020 + n*0x040 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - - - terr trc rcz
167 32059l?avr32?01/2012 at32uc3b 16.6.12 interrupt disable register name: idr access type: write-only offset: 0x024 + n*0x040 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - - - terr trc rcz
168 32059l?avr32?01/2012 at32uc3b 16.6.13 interrupt mask register name: imr access type: read-only offset: 0x028 + n*0x040 reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. a bit in this register is cleared when the corresponding bit in idr is written to one. a bit in this register is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - - - terr trc rcz
169 32059l?avr32?01/2012 at32uc3b 16.6.14 interrupt status register name: isr access type: read-only offset: 0x02c + n*0x040 reset value: 0x00000000 ? terr: transfer error this bit is cleared when no transfer errors have occurred since the last write to cr.eclr. this bit is set when one or more transfer errors has occurred since reset or the last write to cr.eclr. ? trc: transfer complete this bit is cleared when the tcr and/or the tcrr holds a non-zero value. this bit is set when both the tcr and the tcrr are zero. ? rcz: reload counter zero this bit is cleared when the tcrr holds a non-zero value. this bit is set when tcrr is zero. ? 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - - - terr trc rcz
170 32059l?avr32?01/2012 at32uc3b 16.7 module configuration the specific configuration for the pdca in stance is listed in the following tables. 16.7.1 dma handshake signals the following table defines the valid settings fo r the peripheral identifier (pid) in the pdca peripheral select register (psr).). table 16-4. pdca configuration features pdca number of channels 7 table 16-5. register reset values register reset value psrn n table 16-6. pdca handshake signals pid value peripheral module & direction 0adc 1 ssc - rx 2 usart0 - rx 3 usart1 - rx 4 usart2 - rx 5twi - rx 6 spi0 - rx 7 ssc - tx 8 usart0 - tx 9 usart1 - tx 10 usart2 - tx 11 twi - tx 12 spi0 - tx 13 abdac - tx
171 32059l?avr32?01/2012 at32uc3b 17. general-purpose input/ output controller (gpio) rev: 1.1.0.4 17.1 features each i/o line of the gpio features: ? configurable pin-change, rising-edge or falling-edge interrupt on any i/o line ? a glitch filter providing rejection of pulses shorter than one clock cycle ? input visibility and output control ? multiplexing of up to four peripheral functions per i/o line ? programmable internal pull-up resistor 17.2 overview the general purpose input/output controller mana ges the i/o pins of th e microcontroller. each i/o line may be dedicated as a general-purpose i/o or be assigned to a function of an embedded peripheral. this assures effective opt imization of the pins of a product. 17.3 block diagram figure 17-1. gpio block diagram 17.4 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. interrupt controller power manager embedded peripheral general purpose input/output - gpio gpio interrupt request clk_gpio pin control signals pin pin pin pin pin mcu i/o pins pb configuration interface
172 32059l?avr32?01/2012 at32uc3b 17.4.1 module configuration most of the features of the gpio are configurable for each product. the user must refer to the package and pinout chapter for these settings. product specific settings includes: ? number of i/o pins. ? functions implemented on each pin ? peripheral function(s) mult iplexed on each i/o pin ? reset value of registers 17.4.2 clocks the clock for the gpio bus interface (clk_g pio) is generated by the power manager. this clock is enabled at reset, and can be disabled in the power manager. the clk_gpio must be enabled in order to access the configuration registers of the gpio or to use the gpio interrupts. after configuring the gp io, the clk_gpio can be disabled if interrupts are not used. 17.4.3 interrupts the gpio interrupt lines are connected to the interrupt controller. using the gpio interrupt requires the interrupt controller to be configured first. 17.5 functional description the gpio controls the i/o lines of the microcont roller. the control logic associated with each pin is represented in the figure below:
173 32059l?avr32?01/2012 at32uc3b figure 17-2. overview of the gpio pad connections 17.5.1 basic operation 17.5.1.1 i/o line or peripheral function selection when a pin is multiplexed with one or more peri pheral functions, the selection is controlled with the gpio enable register (gper). if a bit in gper is written to one, the corresponding pin is controlled by the gpio. if a bit is written to zero , the corresponding pin is controlled by a periph- eral function. 17.5.1.2 peripheral selection the gpio provides multiplexing of up to four pe ripheral functions on a si ngle pin. the selection is performed by accessing peripheral mux register 0 (pmr0) and peripheral mux register 1 (pmr1). 17.5.1.3 output control when the i/o line is assigned to a peripheral functi on, i.e. the corresponding bit in gper is writ- ten to zero, the drive of the i/o line is controlle d by the peripheral. the peripheral, depending on the value in pmr0 and pmr1, determines whether the pin is driven or not. when the i/o line is controlled by the gpio, the value of the output driver enable register (oder) determines if the pin is driv en or not. when a bit in this register is written to one, the cor- 0 1 gper 1 0 ovr oder pmr1 periph. a output enable periph. b output enable periph. c output enable periph. d output enable periph. a output data periph. b output data periph. c output data periph. d output data pad puer periph. a input data periph. b input data periph. c input data periph. d input data pvr 0 1 glitch filter gfer edge detector 1 0 interrupt request imr1 pmr0 imr0 ier
174 32059l?avr32?01/2012 at32uc3b responding i/o line is driven by the gpio. when the bit is written to zero, the gpio does not drive the line. the level driven on an i/o line can be determined by writing to the output value register (ovr). 17.5.1.4 inputs the level on each i/o line can be read through th e pin value register (pvr). this register indi- cates the level of the i/o lines re gardless of whether the lines are driven by the gpio or by an external component. note that due to power saving measures, the pvr register can only be read when gper is written to one for the corresp onding pin or if interrupt is enabled for the pin. 17.5.1.5 output line timings the figure below shows the timing of the i/o line when writing a one and a zero to ovr. the same timing applies when performing a ?set? or ?cl ear? access, i.e., writing a one to the output value set register (ovrs) or the output val ue clear register (ovrc). the timing of pvr is also shown. figure 17-3. output line timings 17.5.2 advanced operation 17.5.2.1 pull-up resistor control each i/o line is designed with an embedded pull-up resistor. the pull-up resistor can be enabled or disabled by writing a one or a zero to t he corresponding bit in t he pull-up enable register (puer). control of the pull-up resistor is possi ble whether an i/o line is controlled by a periph- eral or the gpio. 17.5.2.2 input glitch filter optional input glitch filters can be enabled on each i/o line. when the glitch filter is enabled, a glitch with duration of less than 1 clock cycle is automatically rejected, while a pulse with dura- tion of 2 clock cycles or more is accepted. for pulse durations between 1 clock cycle and 2 clock cycles, the pulse may or may not be taken into account, depending on the precise timing of its occurrence. thus for a pulse to be guaranteed visi ble it must exceed 2 clock cycles, whereas for a glitch to be reliably filtered out, its duration must not exceed 1 clock cycle. the filter introduces 2 clock cycles of latency. the glitch filters are controlled by the glitch filter enable register (gfer). when a bit is written to one in gfer, the glitch filter on the corresponding pin is enabled. the glitch filter affects only interrupt inputs. in puts to peripherals or the value read through pvr are not affected by the glitch filters. pb access pb access clk_gpio write ovr to 1 write ovr to 0 ovr / i/o line pvr
175 32059l?avr32?01/2012 at32uc3b 17.5.3 interrupts the gpio can be configured to generate an inte rrupt when it detects an input change on an i/o line. the module can be configured to signal an interrupt whenever a pin changes value or only to trigger on rising edges or fa lling edges. interr upts are enabled on a pin by writing a one to the corresponding bit in the interrupt enable register (ier). the interrupt mode is set by writing to the interrupt mode register 0 (imr0) and the inte rrupt mode register 1(imr1). interrupts can be enabled on a pin, regardless of the configuration of the i/o line, i.e. whether it is controlled by the gpio or assigned to a peripheral function. in every port there are four interrupt lines connected to the interrupt controller. groups of eight interrupts in the port are ored together to form an interrupt line. when an interrupt event is detected on an i/o line, and the corresponding bit in ier is written to one, the gpio interrupt request line is asserted. a number of interrupt signals are ored-wired together to generate a single interr upt signal to the interrupt controller. the interrupt flag register (ifr) can by read to determine which pin(s) caused the interrupt. the interrupt bit must be cleared by writing a one to the interrupt flag clear register (ifrc). to take effect, the clear operation must be perform ed when the interrupt line is enabled in ier. oth- erwise, it will be ignored. gpio interrupts can only be triggered when the clk_gpio is enabled. 17.5.4 interrupt timings the figure below shows the timing for rising edge (o r pin-change) interrupts when the glitch filter is disabled. for the pulse to be registered, it mu st be sampled at the rising edge of the clock. in this example, this is not the case for the first pulse. the second pulse is however sampled on a rising edge and will trigge r an interr upt request. figure 17-4. interrupt timing with glitch filter disabled the figure below shows the timing for rising edge (o r pin-change) interrupts when the glitch filter is enabled. for the pulse to be registered, it must be sampled on two subsequent rising edges. in the example, the first pulse is rejected while the second pulse is accepted and causes an interrupt request. figure 17-5. interrupt timing with glitch filter enabled clock pin level gpio_ifr clock pin level gpio_ifr
176 32059l?avr32?01/2012 at32uc3b 17.6 user interface the gpio controls all the i/o pins on the avr32 microcontroller. the pins are managed as 32- bit ports that are configurable through a pb interf ace. each port has a se t of configuration regis- ters. the overall memory map of the gpio is shown below. the number of pins and hence the number of ports are product specific. figure 17-6. overall mermory map in the gpio controller function multiplexingtable in the package and pinout chapter, each gpio line has a unique number. note that the pa, pb, pc and px ports do not directly corre- spond to the gpio ports. to find the corresponding port and pin the following formula can be used: gpio port = floor((gpio number) / 32), example: floor((36)/32) = 1 gpio pin = gpio number mod 32, example: 36 mod 32 = 4 the table below shows the configuration registers for one port. addresses shown are relative to the port address offset. the specific address of a configuration register is found by adding the port 0 configuration registers port 1 configuration registers port 2 configuration registers port 3 configuration registers port 4 configuration registers 0x0000 0x0100 0x0200 0x0300 0x0400
177 32059l?avr32?01/2012 at32uc3b register offset and the port offset to the gpio st art address. one bit in each of the configuration registers corresponds to an i/o pin. table 17-1. gpio register memory map offset register function name access reset value 0x00 gpio enable register read/write gper read/write (1) 0x04 gpio enable register set gpers write-only 0x08 gpio enable register clear gperc write-only 0x0c gpio enable register toggle gpert write-only 0x10 peripheral mux register 0 read/write pmr0 read/write (1) 0x14 peripheral mux register 0 set pmr0s write-only 0x18 peripheral mux register 0 clear pmr0c write-only 0x1c peripheral mux register 0 toggle pmr0t write-only 0x20 peripheral mux register 1 read/write pmr1 read/write (1) 0x24 peripheral mux register 1 set pmr1s write-only 0x28 peripheral mux register 1 clear pmr1c write-only 0x2c peripheral mux register 1 toggle pmr1t write-only 0x40 output driver enable register read/write oder read/write (1) 0x44 output driver enable register set oders write-only 0x48 output driver enable register clear oderc write-only 0x4c output driver enable register toggle odert write-only 0x50 output value register read/write ovr read/write (1) 0x54 output value register set ovrs write-only 0x58 output value register clear ovrc write-only 0x5c output value register toggle ovrt write-only 0x60 pin value register read pvr read-only (2) 0x70 pull-up enable register read/write puer read/write (1) 0x74 pull-up enable register set puers write-only 0x78 pull-up enable register clear puerc write-only 0x7c pull-up enable register toggle puert write-only 0x90 interrupt enable register read/write ier read/write (1) 0x94 interrupt enable register set iers write-only 0x98 interrupt enable register clear ierc write-only 0x9c interrupt enable register toggle iert write-only 0xa0 interrupt mode register 0 read/write imr0 read/write (1) 0xa4 interrupt mode register 0 set imr0s write-only 0xa8 interrupt mode register 0 clear imr0c write-only 0xac interrupt mode register 0 toggle imr0t write-only 0xb0 interrupt mode register 1 read/write imr1 read/write (1)
178 32059l?avr32?01/2012 at32uc3b 1) the reset value for these registers are device specific. please refer to the module config- uration section at the end of this chapter. 2) the reset value is undefined depending on the pin states. 17.6.1 access types each configuration register can be accessed in four different ways. the first address location can be used to write the register directly. this address can also be used to read the register value. the following addresses fac ilitate three different types of wr ite access to th e register. per- forming a ?set? access, all bits written to one will be set. bits written to ze ro will be unchanged by the operation. performing a ?clear? access, all bits written to one will be cleared. bits written to zero will be unchanged by the o peration. finally, a toggle access will toggle the value of all bits written to one. again all bits written to zero rema in unchanged. note that for some registers (e.g. ifr), not all access methods are permitted. note that for ports with less than 32 bits, t he corresponding control registers will have unused bits. this is also the case for features that ar e not implemented for a specific pin. writing to an unused bit will have no effect. reading unused bits will always return 0. 0xb4 interrupt mode register 1 set imr1s write-only 0xb8 interrupt mode register 1 clear imr1c write-only 0xbc interrupt mode register 1 toggle imr1t write-only 0xc0 glitch filter enable register read/write gfer read/write (1) 0xc4 glitch filter enable register set gfers write-only 0xc8 glitch filter enable register clear gferc write-only 0xcc glitch filter enable register toggle gfert write-only 0xd0 interrupt flag register read ifr read-only (1) 0xd4 interrupt flag register - - - 0xd8 interrupt flag register clear ifrc write-only 0xdc interrupt flag register - - - table 17-1. gpio register memory map offset register function name access reset value
179 32059l?avr32?01/2012 at32uc3b 17.6.2 enable register name: gper access type: read, write, set, clear, toggle offset : 0x00, 0x04, 0x08, 0x0c reset value: - ? p0-p31: pin enable 0: a peripheral function controls the corresponding pin. 1: the gpio controls the corresponding pin. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
180 32059l?avr32?01/2012 at32uc3b 17.6.3 peripheral mux register 0 name: pmr0 access type: read, write, set, clear, toggle offset : 0x10, 0x14, 0x18, 0x1c reset value: - ? p0-31: peripheral multiplexer select bit 0 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
181 32059l?avr32?01/2012 at32uc3b 17.6.4 peripheral mux register 1 name: pmr1 access type: read, write, set, clear, toggle offset : 0x20, 0x24, 0x28, 0x2c reset value: - ? p0-31: peripheral multiplexer select bit 1 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0 {pmr1, pmr0} selected peripheral function 00 a 01 b 10 c 11 d
182 32059l?avr32?01/2012 at32uc3b 17.6.5 output driver enable register name: oder access type: read, write, set, clear, toggle offset : 0x40, 0x44, 0x48, 0x4c reset value: - ? p0-31: output driver enable 0: the output driver is disabled for the corresponding pin. 1: the output driver is enabled for the corresponding pin. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
183 32059l?avr32?01/2012 at32uc3b 17.6.6 output value register name: ovr access type: read, write, set, clear, toggle offset : 0x50, 0x54, 0x58, 0x5c reset value: - ? p0-31: output value 0: the value to be driven on the i/o line is 0. 1: the value to be driven on the i/o line is 1. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
184 32059l?avr32?01/2012 at32uc3b 17.6.7 pin value register name: pvr access type: read offset : 0x60, 0x64, 0x68, 0x6c reset value: - ? p0-31: pin value 0: the i/o line is at level ?0?. 1: the i/o line is at level ?1?. note that the level of a pin can only be read when gper is set or interrupt is enabled for the pin. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
185 32059l?avr32?01/2012 at32uc3b 17.6.8 pull-up enable register name: puer access type: read, write, set, clear, toggle offset : 0x70, 0x74, 0x78, 0x7c reset value: - ? p0-31: pull-up enable 0: the internal pull-up resistor is disabled for the corresponding pin. 1: the internal pull-up resistor is enabled for the corresponding pin. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
186 32059l?avr32?01/2012 at32uc3b 17.6.9 interrupt enable register name: ier access type: read, write, set, clear, toggle offset : 0x90, 0x94, 0x98, 0x9c reset value: - ? p0-31: interrupt enable 0: interrupt is disabled for the corresponding pin. 1: interrupt is enabled for the corresponding pin. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
187 32059l?avr32?01/2012 at32uc3b 17.6.10 interrupt mode register 0 name: imr0 access type: read, write, set, clear, toggle offset : 0xa0, 0xa4, 0xa8, 0xac reset value: - ? p0-31: interrupt mode bit 0 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
188 32059l?avr32?01/2012 at32uc3b 17.6.11 interrupt mode register 1 name: imr1 access type: read, write, set, clear, toggle offset : 0xb0, 0xb4, 0xb8, 0xbc reset value: - ? p0-31: interrupt mode bit 1 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0 {imr1, imr0} interrupt mode 00 pin change 01 rising edge 10 falling edge 11 reserved
189 32059l?avr32?01/2012 at32uc3b 17.6.12 glitch filter enable register name: gfer access type: read, write, set, clear, toggle offset : 0xc0, 0xc4, 0xc8, 0xcc reset value: - ? p0-31: glitch filter enable 0: glitch filter is disabled for the corresponding pin. 1: glitch filter is enabled for the corresponding pin. note! the value of this register should only be changed wh en ier is ?0?. updating this gfer while interrupt on the corresponding pin is enabled can cause an unintentional interrupt to be triggered. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
190 32059l?avr32?01/2012 at32uc3b 17.6.13 interrupt flag register name: ifr access type: read, clear offset : 0xd0, 0xd8 reset value: - ? p0-31: interrupt flag 1: an interrupt condition has been detected on the corresponding pin. 0: no interrupt condition has beedn detected on the corresponding pin since reset or the last time it was cleared. the number of interrupt request lines is dependant on the number of i/o pins on the mcu. refer to the product specific data for details. note also that a bit in the interrupt flag register is only valid if the corresponding bit in ier is set. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
191 32059l?avr32?01/2012 at32uc3b 17.7 programming examples 17.7.1 8-bit led-chaser // set r0 to gpio base address mov r0, lo(avr32_gpio_address) orh r0, hi(avr32_gpio_address) // enable gpio control of pin 0-8 mov r1, 0xff st.w r0[avr32_gpio_gpers], r1 // set initial value of port mov r2, 0x01 st.w r0[avr32_gpio_ovrs], r2 // set up toggle value. two pins are toggled // in each round. the bit that is currently set, // and the next bit to be set. mov r2, 0x0303 orh r2, 0x0303 loop: // only change 8 lsb mov r3, 0x00ff and r3, r2 st.w r0[avr32_gpio_ovrt], r3 rol r2 rcall delay rjmp loop it is assumed in this example that a subroutine "delay" exists that re turns after a given time. 17.7.2 configuration of usart pins the example below shows how to configure a peripheral module to control i/o pins. it assumed in this example that the usart receive pin (rxd) is connected to pc16 and that the usart transmit pin (txd) is connected to pc17. for both pins, the usart is peripheral b. in this example, the state of the gpio registers is as sumed to be unknown. the two usart pins are therefore first set to be controlled by the gpio wit h output drivers disabled . the pins can then be assured to be tri-stated while changing the peripheral mux registers. // set up pointer to gpio, portc mov r0, lo(avr32_gpio_address + portc_offset) orh r0, hi(avr32_gpio_address + portc_offset) // disable output drivers
192 32059l?avr32?01/2012 at32uc3b mov r1, 0x0000 orh r1, 0x0003 st.w r0[avr32_gpio_oderc], r1 // make the gpio control the pins st.w r0[avr32_gpio_gpers], r1 // select peripheral b on pc16-pc17 st.w r0[avr32_gpio_pmr0s], r1 st.w r0[avr32_gpio_pmr1c], r1 // enable peripheral control st.w r0[avr32_gpio_gperc], r1
193 32059l?avr32?01/2012 at32uc3b 17.8 module configuration the specific configuration for eac h gpio instance is listed in the following tables. the module bus clocks listed here are conn ected to the system bus clocks. refer to the power manager chapter for details. the reset values for all gpio registers are zero, with the following exceptions: table 17-2. module configuration feature gpio number of gpio ports 2 number of peripheral functions 4 table 17-3. module clock name module name clock name gpio clk_gpio table 17-4. register reset values port register reset value 0 gper 0xffffffff 0 pmr0 0x00000000 0 pmr1 0x00000000 0 oder 0x00000000 0 ovr 0x00000000 0 puer 0x00000000 0 ier 0x00000000 0 imr0 0x00000000 0 imr1 0x00000000 0 gfer 0x00000000 0 ifr 0xffffffff 1 gper 0x00000fff 1 pmr0 0x00000000 1 pmr1 0x00000000 1 oder 0x00000000 1 ovr 0x00000000 1 puer 0x00000000 1 ier 0x00000000 1 imr0 0x00000000 1 imr1 0x00000000 1 gfer 0x00000000 1 ifr 0x00000fff
194 32059l?avr32?01/2012 at32uc3b 18. serial peripheral interface (spi) rev. 1.9.9.2 18.1 features ? supports communication with serial external devices ? four chip selects with external decoder support allow communication with up to 15 peripherals ? serial memories, such as da taflash and 3-wire eeproms ? serial peripherals, such as adcs, dacs, lcd controllers, can controllers and sensors ? external co-processors ? master or slave serial peripheral bus interface ? 8 - to 16-bit programmable data length per chip select ? programmable phase and po larity per chip select ? programmable transfer delays between consecutive transfers and between clock and data per chip select ? programmable delay between consecutive transfers ? selectable mode fault detection ? connection to pdca channel capabilities optimizes data transfers ? one channel for the receiver, one channel for the transmitter ? next buffer support 18.2 overview the serial peripheral interface (spi) circuit is a synchronous serial data link that provides com- munication with external devices in master or slave mode. it also enables communication between processors if an external pr ocessor is connected to the system. the serial peripheral interface is essentially a shift register that serially transmits data bits to other spis. during a data transfer, one spi syste m acts as the ?master?' which controls the data flow, while the other devices act as ?slaves'' whic h have data shifted into and out by the master. different cpus can take turn being masters (mult iple master protocol opposite to single master protocol where one cpu is always the master while all of the others are always slaves) and one master may simultaneously shift da ta into multiple slaves. howeve r, only one slave may drive its output to write data back to the master at any given time. a slave device is selected when the master asse rts its nss signal. if multiple slave devices exist, the master generates a separate slave select sig nal for each slave (npcs). the spi system consists of two data lines and two control lines: ? master out slave in (mosi): this data line suppl ies the output data fr om the master shifted into the input(s) of the slave(s). ? master in slave out (miso): this data line supplies the output data from a slave to the input of the master. there may be no more than one slave transmitting data during any particular transfer. ? serial clock (spck): this control line is driven by the master and regulates the flow of the data bits. the master may transmit data at a variety of baud rates; the spck line cycles once for each bit that is transmitted. ? slave select (nss): this control line allows slaves to be turned on and off by hardware.
195 32059l?avr32?01/2012 at32uc3b 18.3 block diagram figure 18-1. block diagram 18.4 application block diagram figure 18-2. application block diagram: single master/multiple slave implementation spi interface interrupt control pdca gpio clk_spi peripheral bus spck npcs3 npcs2 npcs1 npcs0/nss mosi miso spi interrupt div clk_spi 32 slave 0 slave 2 slave 1 spck npcs3 npcs2 npcs1 npcs0 mosi miso spi master spck nss mosi miso spck nss mosi miso spck nss mosi miso nc
196 32059l?avr32?01/2012 at32uc3b 18.5 signal description 18.6 product dependencies 18.6.1 i/o lines the pins used for interfacing the compliant exte rnal devices may be multiplexed with gpio lines. the programmer must first program the gpio contro ller to assign the spi pins to their peripheral functions.to use the local loopback function the spi pins must be controlled by the spi. 18.6.2 power management the spi may be clocked through the power manager, before using the spi, the programmer must ensure that the spi clock is enabled in the power manager. in the spi description, clk_spi is the clock of the peripheral bus to which the spi is connected. 18.6.3 interrupt the spi interface has an interrupt line connected to the interrupt controller (intc). handling the spi interrupt requires programming the intc before configuring the spi. 18.7 functional description 18.7.1 modes of operation the spi operates in master mode or in slave mode. operation in master mode is programmed by writ ing at 1 the mstr bit in the mode register. the pins npcs0 to npcs3 are all configured as outputs, the spck pin is driven, the miso line is wired on the receiver input and the mosi line driven as an output by the transmitter. if the mstr bit is written at 0, the spi operates in slave mode. the miso line is driven by the transmitter output, the mosi line is wired on the re ceiver input, the spck pin is driven by the transmitter to synchronize the receiver. the npcs0 pin becomes an input, and is used as a slave select signal (nss). the pins npcs1 to npcs3 are not driven and can be used for other purposes. the data transfers are identically programmable for both modes of operations. the baud rate generator is activated only in master mode. 18.7.2 data transfer four combinations of polarity and phase are available for data transfers. the clock polarity is programmed with the cpol bit in the chip sele ct register. the clock phase is programmed with table 18-1. pin name pin description type master slave miso master in slave out input output mosi master out slave in output input spck serial clock output input npcs1-npcs3 peripheral chip selects output unused npcs0/nss peripheral chip select/slave select output input
197 32059l?avr32?01/2012 at32uc3b the ncpha bit. these two parameters determine th e edges of the clock signal on which data is driven and sampled. each of the two parameters has two possible states, resulting in four possi- ble combinations that are incompatible with one an other. thus, a master/slave pair must use the same parameter pair values to communicate. if multiple slaves are used and fixed in different configurations, the master must reconfigure itself each time it needs to communicate with a dif- ferent slave. table 18-2 shows the four modes and corresponding parameter settings. figure 18-3 on page 197 and figure 18-4 on page 197 show examples of data transfers. figure 18-3. spi transfer format (ncpha = 1, 8 bits per transfer) figure 18-4. spi transfer format (ncpha = 0, 8 bits per transfer) table 18-2. spi modes spi mode cpol ncpha 001 100 211 310 14 3 2 58 7 6 spck cycle (for reference) spck (cpol = 0) nss (to slave) miso (from slave) mosi (from master) spck (cpol = 1) msb 6 4 5lsb 1 2 3 msb 6 *** lsb 1 2 3 4 5 *** not defined, but normaly msb of previous character received 14 3 2 58 7 6 spck cycle (for reference) spck (cpol = 0) nss (to slave) miso (from slave) mosi (from master) spck (cpol = 1) msb 6 4 5lsb 1 2 3 6 lsb 1 2 3 4 5 msb ***
198 32059l?avr32?01/2012 at32uc3b 18.7.3 master mode operations when configured in master mode, the spi uses the internal programmable baud rate generator as clock source. it fully controls the data transfers to and from the slave(s) connected to the spi bus. the spi drives the chip select line to the slave and the serial clock signal (spck). the spi features two holding registers, the trans mit data register and the receive data regis- ter, and a single shift register. the holding regist ers maintain the data flow at a constant rate. after enabling the spi, a data transfer begins when the processor writes to the tdr (transmit data register). the written data is immediately transferred in the shift register and transfer on the spi bus starts. while the data in the shift re gister is shifted on the mosi line, the miso line is sampled and shifted in the shift register . transmission cannot occur without reception. before writing the tdr, the pcs field mu st be set in order to select a slave. if new data is written in tdr during the transfer, it stays in it until the current transfer is com- pleted. then, the received data is transferred from the shift register to rdr, the data in tdr is loaded in the shift register and a new transfer starts. the transfer of a data written in tdr in the shift register is indicated by the tdre bit (transmit data register empty) in the status register (s r). when new data is written in tdr, this bit is cleared. the tdre bit is used to trigger th e transmit peripheral dma controller channel. the end of transfer is indicated by the txempty fl ag in the sr register. if a transfer delay (dly- bct) is greater than 0 for the last transfer, txempty is set after the completion of said delay. the clk_spi can be switc hed off at this time. the transfer of received data from the shift re gister in rdr is indicated by the rdrf bit (receive data register full) in the status r egister (sr). when the received data is read, the rdrf bit is cleared. if the rdr (receive data register) has not bee n read before new data is received, the overrun error bit (ovres) in sr is set. when this bit is set the spi will continue to update rdr when data is received, overwriting the previously receiv ed data. the user has to read the status regis- ter to clear the ovres bit. figure 18-5 on page 199 shows a block diagram of the spi when operating in master mode. fig- ure 18-6 on page 200 shows a flow chart describing how transfers are handled.
199 32059l?avr32?01/2012 at32uc3b 18.7.3.1 master mode block diagram figure 18-5. master mode block diagram baud rate generator shift register tdre ps pcsdec current peripheral modf modfdis mstr scbr csr0..3 csr0..3 cpol ncpha bits rdr rd rdrf ovres td tdr rdr csaat csr0..3 pcs mr pcs tdr spck clk_spi miso mosi msb lsb npcs1 npcs2 npcs3 npcs0 spi clock 0 1 npcs0
200 32059l?avr32?01/2012 at32uc3b 18.7.3.2 master mode flow diagram figure 18-6. master mode flow diagram
201 32059l?avr32?01/2012 at32uc3b 18.7.3.3 clock generation the spi baud rate clock is generated by dividi ng the clk_spi by a value between 1 and 255. this allows a maximum operating baud rate at up to clk_spi and a minimum operating baud rate of clk_spi divided by 255. programming the scbr field at 0 is forbidden. tr iggering a transfer while scbr is at 0 can lead to unpredictable results. at reset, scbr is 0 and the user has to program it at a valid value before performing the first transfer. the divisor can be defined independently for each chip select, as it has to be programmed in the scbr field of the chip select registers. this allows the spi to automatically adapt the baud rate for each interfaced peripheral without reprogramming. 18.7.3.4 transfer delays figure 18-7 on page 201 shows a chip select transfer change and consecutive transfers on the same chip select. three delays can be pr ogrammed to modify th e transfer waveforms: ? the delay between chip selects, programmable only once for all the chip selects by writing the dlybcs field in the mode register. allows insertion of a delay between release of one chip select and before assertion of a new one. ? the delay before spck, independently programm able for each chip select by writing the field dlybs. allows the start of spck to be delayed after the chip select has been asserted. ? the delay between consecutive transfers, independently programmable for each chip select by writing the dlybct field. a llows insertion of a delay between two transfers occurring on the same chip select these delays allow the spi to be adapted to the interfaced peripherals and their speed and bus release time. figure 18-7. programmable delays dlybcs dlybs dlybct dlybct chip select 1 chip select 2 spck
202 32059l?avr32?01/2012 at32uc3b 18.7.3.5 peripheral selection the serial peripherals are selected through the assertion of the npcs 0 to npcs3 signals. by default, all the npcs signals are high before and after each transfer. the peripheral selection can be performed in two different ways: ? fixed peripheral select: spi exch anges data with only one peripheral ? variable peripheral select: data can be exchanged with more than one peripheral fixed peripheral select is activat ed by writing the ps bit to zero in mr (mode register). in this case, the current peripheral is defined by the pcs field in mr and the pcs field in the tdr has no effect. variable peripheral select is activated by setti ng ps bit to one. the pcs field in tdr is used to select the current peripheral. this means that the peripheral selection can be defined for each new data. the fixed peripheral selection allows buffer tran sfers with a single peripheral. using the periph- eral dma controller is an optimal means, as the size of the data transfer between the memory and the spi is either 8 bits or 16 bits. however, changing the peripheral selection requires the mode register to be reprogrammed. the variable peripheral selection allows buffer transfers with multiple per ipherals without repro- gramming the mode register. data written in tdr is 32 bits wide and defines the real data to be transmitted and the peripheral it is destined to. using the peripheral dma controller in this mode requires 32-bit wide buffers, with the data in the lsbs and the pcs and lastxfer fields in the msbs, however the spi still controls the number of bits (8 to16) to be transferred through miso and mosi lines with the chip select configuration registers. this is not the optimal means in term of memory size for the buffers, bu t it provides a very effective means to exchange data with sev- eral peripherals without any in tervention of the processor. 18.7.3.6 peripheral chip select decoding the user can program the spi to operate with up to 15 peripherals by decoding the four chip select lines, npcs0 to npcs3 with an external l ogic. this can be enabled by writing the pcs- dec bit at 1 in the mode register (mr). when operating without decoding, the spi makes sure that in any case only one chip select line is activated, i.e. driven low at a time. if two bi ts are defined low in a pcs field, only the lowest numbered chip select is driven low. when operating with decoding, the spi directly outputs the value defi ned by the pcs field of either the mode register or the transmit data register (depending on ps). as the spi sets a default value of 0xf on the chip select lines (i.e. all chip select lines at 1) when not processing any transfer, only 15 peripherals can be decoded. the spi has only four chip select registers, not 15. as a result, when decoding is activated, each chip select defines the characteristics of up to four peripherals. as an example, crs0 defines the characterist ics of the externally decoded peripher als 0 to 3, corresponding to the pcs values 0x0 to 0x3. thus, the user has to make sure to connect compatible peripherals on the decoded chip select lines 0 to 3, 4 to 7, 8 to 11 and 12 to 14. 18.7.3.7 peripheral deselection when operating normally, as soon as the transfer of the last data written in tdr is completed, the npcs lines all rise. this might lead to runtim e error if the processor is too long in responding
203 32059l?avr32?01/2012 at32uc3b to an interrupt, and thus might lead to difficulties for interfac ing with some serial peripherals requiring the chip select li ne to remain active during a full set of transfers. to facilitate interfacing with such devices, the chip select regi ster can be programmed with the csaat bit (chip select active afte r transfer) at 1. this allows th e chip select lines to remain in their current state (low = active) until tr ansfer to another peripheral is required. figure 18-8 on page 203 shows different peripheral deselection cases and the effect of the csaat bits. figure 18-8. peripheral deselection 18.7.3.8 mode fault detection a mode fault is detected when the spi is progr ammed in master mode and a low level is driven by an external master on the npcs0/nss signa l. npcs0, mosi, miso and spck must be con- figured in open drain through the gpio controller, so that external pull up resistors are needed to guarantee high level. when a mode fault is detected, the modf bit in th e sr is set until the sr is read and the spi is automatically disabled until re-enabled by writin g the spien bit in the cr (control register) at 1. by default, the mode fault detection circuitr y is enabled. the user can disable mode fault detection by setting the modfdis bit in the spi mode register (mr). a npcs[0..3] write spi_tdr tdre npcs[0..3] write spi_tdr tdre npcs[0..3] write spi_tdr tdre dlybcs pcs = a dlybcs dlybct a pcs = b b dlybcs pcs = a dlybcs dlybct a pcs = b b dlybcs dlybct pcs=a a dlybcs dlybct a pcs = a a a dlybct aa csaat = 0 dlybct aa csaat = 1 a
204 32059l?avr32?01/2012 at32uc3b 18.7.4 spi slave mode when operating in slave mode, the spi processe s data bits on the clock provided on the spi clock pin (spck). the spi waits for nss to go acti ve before receiving the serial clock from an external master. when nss falls, the clock is validated on the serializer, which processes the number of bits defined by the bits field of th e chip select register 0 (csr0). these bits are processed follow- ing a phase and a polarity defined respectively by the ncpha and cpol bits of the csr0. note that bits, cpol and ncpha of th e other chip select registers have no effect when the spi is programmed in slave mode. the bits are shifted out on the miso line and sampled on the mosi line. when all the bits are processed, the received da ta is transferred in the receive data register and the rdrf bit rises. if the rdr (receive data register) has not been read before new data is received, the overrun error bit (ovres) in sr is set. data is loaded in rdr even if this flag is set. the user has to read the stat us register to clear the ovres bit. when a transfer starts, the data shif ted out is the data present in the shift register. if no data has been written in the transmit data register (t dr), the last data received is transferred. if no data has been received since the last reset, all bits are transmitted low, as the shift register resets at 0. when a first data is written in tdr, it is trans ferred immediately in the shift register and the tdre bit rises. if new data is wr itten, it remains in tdr until a transfer occurs, i.e. nss falls and there is a valid clock on the spck pin. when the transfer occurs, the last data written in tdr is transferred in the shift register and the tdre bi t rises. this enables frequent updates of critical variables with single transfers. then, a new data is loaded in the shift register from the transmit data register. in case no character is ready to be transmitted, i.e. no c haracter has been written in tdr since the last load from tdr to the shift register, the shift register is not modified and the last received character is retransmitted. figure 18-9 on page 205 shows a block diagram of the spi when operating in slave mode.
205 32059l?avr32?01/2012 at32uc3b figure 18-9. slave mode functional block diagram shift register spck spiens lsb msb nss mosi spi_rdr rd spi clock tdre spi_tdr td rdrf ovres spi_csr0 cpol ncpha bits fload spien spidis miso
206 32059l?avr32?01/2012 at32uc3b 18.8 user interface note: 1. values in the version register vary with the version of the ip block implementation. table 18-3. spi register memory map offset register name access reset 0x00 control register cr write-only 0x00000000 0x04 mode register mr read/write 0x00000000 0x08 receive data register rdr read-only 0x00000000 0x0c transmit data register tdr write-only 0x00000000 0x10 status register sr read-only 0x000000f0 0x14 interrupt enable register ier write-only 0x00000000 0x18 interrupt disable register idr write-only 0x00000000 0x1c interrupt mask register imr read-only 0x00000000 0x30 chip select register 0 csr0 read/write 0x00000000 0x34 chip select register 1 csr1 read/write 0x00000000 0x38 chip select register 2 csr2 read/write 0x00000000 0x3c chip select register 3 csr3 read/write 0x00000000 0x00fc version register version read-only 0x- (1)
207 32059l?avr32?01/2012 at32uc3b 18.8.1 control register name: cr access type: write-only offset: 0x00 reset value: 0x00000000 ? lastxfer: last transfer 0: no effect. 1: the current npcs will be deasserted after the character writt en in td has been transferred. when csaat is set, this allows to close the communication with the current serial peripheral by raising the corresponding npcs line as soon as td transfer has completed. ? swrst: spi software reset 0: no effect. 1: reset the spi. a software-triggered hardware reset of the spi interface is performed. the spi is in slave mode after software reset. peripheral dma controller channels are not affected by software reset. ? spidis: spi disable 0: no effect. 1: disables the spi. as soon as spidis is set, spi finishes its tranfer. all pins are set in input mode and no data is received or transmitted. if a transfer is in progress, the transfer is finished before the spi is disabled. if both spien and spidis are equal to one when the control register is written, the spi is disabled. ? spien: spi enable 0: no effect. 1: enables the spi to transfer and receive data. 31 30 29 28 27 26 25 24 ???????lastxfer 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ??????? - 76543210 swrst?????spidisspien
208 32059l?avr32?01/2012 at32uc3b 18.8.2 mode register name: mr access type: read/write offset: 0x04 reset value: 0x00000000 ? dlybcs: delay between chip selects this field defines the delay from npcs inactive to the activation of another npcs. the dlybcs time guarantees non- overlapping chip selects and solves bus contentions in case of peripherals having long data float times. if dlybcs is less than or equal to six, six clk_spi periods will be inserted by default. otherwise, the following equation determines the delay: ? pcs: peripheral chip select this field is only used if fixed peripheral select is active (ps = 0). if pcsdec = 0: pcs = xxx0npcs[3:0] = 1110 pcs = xx01npcs[3:0] = 1101 pcs = x011npcs[3:0] = 1011 pcs = 0111npcs[3:0] = 0111 pcs = 1111forbidden (no peri pheral is selected) (x = don?t care) if pcsdec = 1: npcs[3:0] output signals = pcs. ? llb: local loopback enable 0: local loopback path disabled. 1: local loopback path enabled ( llb controls the local loopback on the data serializer for testi ng in master mode only. (miso is internally connected on mosi.) ? modfdis: mode fault detection 0: mode fault detection is enabled. 1: mode fault detection is disabled. ? pcsdec: chip select decode 0: the chip selects are directly connected to a peripheral device. 1: the four chip select lines are connected to a 4- to 16-bit decoder. when pcsdec equals one, up to 15 chip select signals can be generated with the four lines using an external 4- to 16-bit decoder. the chip select registers define the characteristics of the 15 chip selects according to the following rules: csr0 defines peripheral chip select signals 0 to 3. csr1 defines peripheral chip select signals 4 to 7. csr2 defines peripheral chip select signals 8 to 11. 31 30 29 28 27 26 25 24 dlybcs 23 22 21 20 19 18 17 16 ???? pcs 15 14 13 12 11 10 9 8 ???????? 76543210 llb - - modfdis ? pcsdec ps mstr delay between chip selects dlybcs clkspi ---------------------- - =
209 32059l?avr32?01/2012 at32uc3b csr3 defines peripheral chip select signals 12 to 14. ? ps: peripheral select 0: fixed peripheral select. 1: variable peripheral select. ? mstr: master/slave mode 0: spi is in slave mode. 1: spi is in master mode.
210 32059l?avr32?01/2012 at32uc3b 18.8.3 receive data register name: rdr access type: read-only offset: 0x08 reset value: 0x00000000 ? rd: receive data data received by the spi interface is stored in this register right-justified. unused bits read zero. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 rd 76543210 rd
211 32059l?avr32?01/2012 at32uc3b 18.8.4 transmit data register name: tdr access type: write-only offset: 0x0c reset value: 0x00000000 ? lastxfer: last transfer 0: no effect. 1: the current npcs will be deasserted after the character writt en in td has been transferred. when csaat is set, this allows to close the communication with the current serial peripheral by raising the corresponding npcs line as soon as td transfer has completed. this field is only used if variable peripheral select is active (ps = 1). ? pcs: peripheral chip select this field is only used if variable peripheral select is active (ps = 1). if pcsdec = 0: pcs = xxx0npcs[3:0] = 1110 pcs = xx01npcs[3:0] = 1101 pcs = x011npcs[3:0] = 1011 pcs = 0111npcs[3:0] = 0111 pcs = 1111forbidden (no peri pheral is selected) (x = don?t care) if pcsdec = 1: npcs[3:0] output signals = pcs ? td: transmit data data to be transmitted by the spi interfac e is stored in this register. information to be transmitted must be written to the transmit data register in a right-justified format. 31 30 29 28 27 26 25 24 ???????lastxfer 23 22 21 20 19 18 17 16 ???? pcs 15 14 13 12 11 10 9 8 td 76543210 td
212 32059l?avr32?01/2012 at32uc3b 18.8.5 status register name: sr access type: read-only offset: 0x10 reset value: 0x00000000 ? spiens: spi enable status 0: spi is disabled. 1: spi is enabled. ? txempty: transmission registers empty 0: as soon as data is written in tdr. 1: tdr and internal shifter are empty. if a transfer delay has been defined, txempty is set after the completion of such delay. ? nssr: nss rising 0: no rising edge detected on nss pin since last read. 1: a rising edge occurred on nss pin since last read. ? ovres: overrun error status 0: no overrun has been detected since the last read of sr. 1: an overrun has occurred since the last read of sr. an overrun occurs when rdr is loaded at least twice from the serializer since the last read of the rdr. ? modf: mode fault error 0: no mode fault has been detected since the last read of sr. 1: a mode fault occurred since the last read of the sr. ? tdre: transmit data register empty 0: data has been written to tdr and not yet transferred to the serializer. 1: the last data written in the transmit data register has been transferred to the serializer. tdre equals zero when the spi is disabled or at reset. the spi enable command sets this bit to one. ? rdrf: receive data register full 0: no data has been received since the last read of rdr 1: data has been received and the received data has been transferred from the serializer to rdr since the last read of rdr. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????spiens 15 14 13 12 11 10 9 8 ????? -txemptynssr 76543210 ????ovresmodftdre rdrf
213 32059l?avr32?01/2012 at32uc3b 18.8.6 interrupt enable register name: ier access type: write-only offset: 0x14 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ????? -txemptynssr 76543210 ????ovresmodftdre rdrf
214 32059l?avr32?01/2012 at32uc3b 18.8.7 interrupt disable register name: idr access type: write-only offset: 0x18 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ????? -txemptynssr 76543210 ????ovresmodftdre rdrf
215 32059l?avr32?01/2012 at32uc3b 18.8.8 interrupt mask register name: imr access type: read-only offset: 0x1c reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. a bit in this register is cleared when the corresponding bit in idr is written to one. a bit in this register is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ????? -txemptynssr 76543210 ????ovresmodftdre rdrf
216 32059l?avr32?01/2012 at32uc3b 18.8.9 chip select register n name: csrn access type: read/write offset: 0x30 +0x04*n reset value: 0x00000000 ? dlybct: delay between consecutive transfers this field defines the delay between two consecutive transfers wi th the same peripheral without removing the chip select. the delay is always inserted after each transfer and before removing the chip select if needed. when dlybct equals zero, no delay between consecutive transfers is inserted and the clock keeps its duty cycle over the character transfers. otherwise, the following equation determines the delay: ? dlybs: delay before spck this field defines the delay from npcs valid to the first valid spck transition. when dlybs equals zero, the npcs valid to spc k transition is 1/2 the spck clock period. otherwise, the following equations determine the delay: i ? iscbr: serial clock baud rate in master mode, the spi interface uses a modulus counter to derive the spck baud rate from the clk_spi. the baud rate is selected by writing a value from 1 to 255 in the scbr field. the following equations determine the spck baud rate: writing 0 to the scbr field is forbidden. triggering a transfer while scbr is 0 can lead to unpredictable results. at reset, scbr is 0 and the user has to write it at a valid value before performing the first transfer. iif a clock divider (scbrn) is set to 1 and the other scbr differ from 1, access on csn is correct but no correct access will b e possible on others cs. 31 30 29 28 27 26 25 24 dlybct 23 22 21 20 19 18 17 16 dlybs 15 14 13 12 11 10 9 8 scbr 76543210 bits csaat csnaat ncpha cpol delay between consecutive transfers 32 dlybct clkspi ------------------------------------ = delay before spck dlybs clkspi --------------------- = spck baudrate clkspi scbr --------------------- =
217 32059l?avr32?01/2012 at32uc3b ? bits: bits per transfer the bits field determines the number of data bits transferred. reserved values should not be used. ? csaat: chip select active after transfer 0: the peripheral chip select line rises as soon as the last transfer is achieved. 1: the peripheral chip select does not rise after the last trans fer is achieved. it remains active until a new transfer is requ ested on a different chip select. ? csnaat: chip select not active after transfer 0 = the peripheral chip select line rises as soon as the last transfer is acheived 1 = the peripheral chip select line rises after every transfer csnaat can be used to force the peripheral chip select line to go inactive after every transfer. this allows successful interfacing to spi slave devices that require this behavior. ? ncpha: clock phase 0: data is changed on the leading edge of spck and captured on the following edge of spck. 1: data is captured on the leading edge of spck and changed on the following edge of spck. ncpha determines which edge of spck causes data to change and which edge causes data to be captured. ncpha is used with cpol to produce the required clock/data relationship between master and slave devices. ? cpol: clock polarity 0: the inactive state value of spck is logic level zero. 1: the inactive state value of spck is logic level one. cpol is used to determine the inactive state value of the seri al clock (spck). it is used with ncpha to produce the required clock/data relationship between master and slave devices. bits bits per transfer 0000 8 0001 9 0010 10 0011 11 0100 12 0101 13 0110 14 0111 15 1000 16 1001 reserved 1010 reserved 1011 reserved 1100 reserved 1101 reserved 1110 reserved 1111 reserved
218 32059l?avr32?01/2012 at32uc3b 19. two-wire interface (twi) 2.1.1.1 19.1 features ? compatible with atmel two-wire interface se rial memory and i2c compatible devices (1) ? one, two or three bytes for slave address ? sequential read-write operations ? master, multi-master and slave mode operation ? bit rate: up to 400 kbits ? general call supported in slave mode ? connection to peripheral dma controller channel capabiliti es optimizes data transfers in master mode only ? one channel for the receiver, one channel for the transmitter ? next buffer support note: 1. see table 19-1 below for details on compatibility with i2c standard. 19.2 overview the atmel two-wire interface (twi) interconnect s components on a unique two-wire bus, made up of one clock line and one data line with speeds of up to 400 kbits per second, based on a byte-oriented transfer format. it can be used with any atmel two-wire interface bus serial eeprom and i2c compatible device such as real time clock (rtc), dot matrix/graphic lcd controllers and temperature sensor, to name but a few. the twi is programmable as a master or a slave with sequential or single-byte access. mu ltiple master capability is supported. arbitra- tion of the bus is performed internally and puts the twi in slave mode automatically if the bus arbitration is lost. a configurable baud rate generator permits the output data rate to be adapted to a wide range of core clock frequencies. below, table 19-1 lists the compatibility level of the atme l two-wire interface in master mode and a full i 2 c compatible device. note: 1. start + b000000001 + ack + sr table 19-1. atmel twi compatibility with i 2 c standard i2c standard atmel twi standard mode speed (100 khz) supported fast mode speed (400 khz) supported 7 or 10 bits slave addressing supported start byte (1) not supported repeated start (sr) condition supported ack and nack management supported slope control and input filtering (fast mode) not supported clock stretching supported
219 32059l?avr32?01/2012 at32uc3b 19.3 list of abbreviations 19.4 block diagram figure 19-1. block diagram table 19-2. abbreviations abbreviation description twi two-wire interface a acknowledge na non acknowledge pstop sstart sr repeated start sadr slave address adr any address except sadr r read wwrite peripheral bus bridge two-wire interface i/o controller twck twd intc twi interrupt power manager clk_twi
220 32059l?avr32?01/2012 at32uc3b 19.5 application block diagram figure 19-2. application block diagram 19.6 i/o lines description 19.7 product dependencies 19.7.1 i/o lines both twd and twck are bidirectional lines, connect ed to a positive supply voltage via a current source or pull-up resistor (see figure 19-2 on page 220 ). when the bus is free, both lines are high. the output stages of dev ices connected to the bus must have an open-drain or open-col- lector to perform the wired-and function. twd and twck pins may be multiplexed with gp io lines. to enable the twi, the programmer must perform the following steps: ? program the gpio controller to: ? dedicate twd and twck as peripheral lines. ? define twd and twck as open-drain. 19.7.2 power management the twi clock is generated by the power manager (pm). before using the twi, the programmer must ensure that the twi clock is enabled in the pm. in the twi description, master clock (clk_twi) is the clock of the peripheral bus to which the twi is connected. table 19-3. i/o lines description pin name pin description type twd two-wire serial data input/output twck two-wire serial clock input/output host with twi interface twd twck atmel twi serial eeprom i2c rtc i2c lcd controller slave 1 slave 2 slave 3 vdd i2c temp. sensor slave 4 rp: pull up value as given by the i2c standard rp rp
221 32059l?avr32?01/2012 at32uc3b 19.7.3 interrupt the twi interface has an interrupt line connected to the interrupt controller (intc). in order to handle interrupts, the intc must be programmed before configuring the twi. 19.8 functional description 19.8.1 transfer format the data put on the twd line must be 8 bits long. data is transferred msb first; each byte must be followed by an acknowledgement. the number of bytes per transfer is unlimited (see figure 19-4 ). each transfer begins with a start conditio n and terminates with a stop condition (see figure 19-3 ). ? a high-to-low transition on the twd line while twck is high defines the start condition. ? a low-to-high transition on the twd line while twck is high defines a stop condition. figure 19-3. start and stop conditions figure 19-4. transfer format 19.9 modes of operation the twi has six modes of operations: ? master transmitter mode ? master receiver mode ? multi-master transmitter mode ? multi-master receiver mode ? slave transmitter mode ? slave receiver mode these modes are described in the following chapters. twd twck start stop twd twck start address r/w ack data ack data ack stop
222 32059l?avr32?01/2012 at32uc3b 19.10 master mode 19.10.1 definition the master is the device which starts a transfer, generates a clock and stops it. 19.10.2 application block diagram figure 19-5. master mode typical ap plication block diagram 19.10.3 programming master mode the following registers have to be programmed before entering master mode: 1. dadr (+ iadrsz + iadr if a 10 bit device is addressed): the device address is used to access slave devices in read or write mode. 2. ckdiv + chdiv + cldiv: de termines cloc k waveform t high and t low . 3. svdis: disable the slave mode. 4. msen: enable the master mode. 19.10.4 master mode clock timing the twi module monitors the state of the twck line as required by the i2c specification. the counter that deter mines the twck t high or t low duration is started whenever a high or low level is detected by the module on twck, not when the module begins releasing or driving the twck line. thus, the cwgr.chdiv and cldiv fields do not alone determ ine the overall twck period; they mere ly determine the t high and t low components, whereas the rise and fall times ( t rise and t fall ) are determined by the external circuitr y on the twck pin as well as the propaga- tion and synchronization delay of twck from the pin back into the twi module. the twi module does not attempt to compensate for these delays, so the overall twi clock period is given by t high +t fall +t low +t rise . 19.10.5 master transmitter mode after the master initiates a star t condition when writin g into the transmit holding register, thr, it sends a 7-bit slave address, configured in th e master mode register (dadr in mmr), to notify the slave device. the bit followi ng the slave address indicates the transfer direction, 0 in this case (mread = 0 in mmr). host with twi interface twd twck atmel twi serial eeprom i2c rtc i2c lcd controller slave 1 slave 2 slave 3 vdd i2c temp. sensor slave 4 rp: pull up value as given by the i2c standard rp rp
223 32059l?avr32?01/2012 at32uc3b the twi transfers require the slave to acknowledge each received byte. during the acknowl- edge clock pulse (9th pulse), the master releases the data line (high), enabling the slave to pull it down in order to generate the acknowledge. t he master polls the data line during this clock pulse and sets the nack in the status register if the slave does not acknowledge the byte. as with the other status bits, an inte rrupt can be generated if enabled in the interrupt enable register (ier). if the slave acknowledges the byte, the data written in the thr, is then shifted in the inter- nal shifter and transferred. when an acknowledge is detected, the txrdy bit is set until a new write in the thr. when no more data is written into the thr, th e master generates a stop condi- tion to end the transfer. the end of the complete transfer is marked by the txcomp bit set to one. see figure 19-6 , figure 19-7 , and figure 19-8 on page 223 . txrdy is used as transmit ready for the pe ripheral dma controller transmit channel. figure 19-6. master write with one data byte figure 19-7. master write with multiple data byte figure 19-8. master write with one byte internal address and multiple data bytes txcomp txrdy write thr (data) stop sent automaticaly (ack received and txrdy = 1) twd a data a s dadr w p a data n a s dadr w data n+5 a p data n+x a txcomp txrdy write thr (data n) write thr (data n+1) write thr (data n+x) last data sent stop sent automaticaly (ack received and txrdy = 1) twd a iadr(7:0) a data n a s dadr w data n+5 a p data n+x a txcomp txrdy twd write thr (data n) write thr (data n+1) write thr (data n+x) last data sent stop sent automaticaly (ack received and txrdy = 1)
224 32059l?avr32?01/2012 at32uc3b 19.10.6 master receiver mode the read sequence begins by setting the start bit. after the start condition has been sent, the master sends a 7-bit slave address to notify th e slave device. the bit following the slave address indicates the transfer direction, 1 in this case (mread = 1 in mmr). during the acknowledge clock pulse (9th pulse), the master releases the data line (high), enabling the slave to pull it down in order to generate the acknowledge. t he master polls the data line during this clock pulse and sets the nack bit in the status regi ster if the slave does not acknowledge the byte. if an acknowledge is received, the master is then ready to receive data from the slave. after data has been received, the master sends an acknowle dge condition to notify the slave that the data has been received except for the last data, after the stop condition. see figure 19-9 . when the rxrdy bit is set in the status register, a charac ter has been received in the receive-holding reg- ister (rhr). the rxrdy bit is reset when reading the rhr. when a single data byte read is performed, with or without internal address (iadr), the start and stop bits must be set at the same time. see figure 19-9 . when a multiple data byte read is performed, with or without iadr, the stop bit must be set after the next-to-last data received. see figure 19-10 . for internal address usage see ?internal address? on page 224 . figure 19-9. master read with one data byte figure 19-10. master read with mu ltiple data bytes rxrdy is used as receive ready for the peripheral dma controller receive channel. 19.10.7 internal address the twi interface can perform various transfe r formats: transfers with 7-bit slave address devices and 10-bit slave address devices. a s dadr r data n p txcomp write start & stop bit rxrdy read rhr twd n a s dadr r data n a a data (n+1) a data (n+m) data (n+m)-1 p twd txcomp write start bit rxrdy write stop bit after next-to-last data read read rhr data n read rhr data (n+1) read rhr data (n+m)-1 read rhr data (n+m)
225 32059l?avr32?01/2012 at32uc3b 19.10.7.1 7-bit slave addressing when addressing 7-bit slave devices, the internal address bytes are used to perform random address (read or write) accesses to reach one or more data bytes, within a memory page loca- tion in a serial memory, for example. when perf orming read operations with an internal address, the twi performs a write operation to set the internal address into the slave device, and then switch to master receiver mode. note that the second start condition (after sending the iadr) is sometimes called ?repeated start? (sr) in i2c fully-compatible devices. see figure 19-12 . see figure 19-11 and figure 19-13 for master write operation with internal address. the three internal address bytes are configurab le through the master mode register (mmr). if the slave device supports only a 7-bit address, i.e. no internal address, iadrsz must be set to 0. n the figures below the following abbreviations are used:i figure 19-11. master write with one, two or three by tes internal address and one data byte ?s start ?sr repeated start ?p stop ?w write ?r read ?a acknowledge ?n not acknowledge ?dadr device address ?iadr internal address s dadr w a iadr(23:16) a iadr(15:8) a iadr(7:0) a data a p s dadr w a iadr(15:8) a iadr(7:0) a p data a a iadr(7:0) a p data a s dadr w twd three bytes internal address two bytes internal address one byte internal address twd twd
226 32059l?avr32?01/2012 at32uc3b figure 19-12. master read with one, two or three by tes internal address and one data byte 19.10.7.2 10-bit slave addressing for a slave address higher than 7 bits, th e user must configure the address size (iadrsz ) and set the other slave address bits in the internal address register (iadr). the two remaining inter- nal address bytes, iadr[15:8] and iadr[23:16 ] can be used the same as in 7-bit slave addressing. example: address a 10-bit device: (10-bit device address is b1 b2 b3 b4 b5 b6 b7 b8 b9 b10) 1. program iadrsz = 1, 2. program dadr with 1 1 1 1 0 b1 b2 (b1 is the msb of the 10-bit address, b2, etc.) 3. program iadr with b3 b4 b5 b6 b7 b8 b9 b10 (b10 is the lsb of the 10-bit address) figure 19-13 below shows a byte write to an atme l at24lc512 eeprom. this demonstrates the use of internal addresses to access the device. figure 19-13. internal address usage 19.11 using the periphe ral dma controller the use of the peripheral dma controlle r significantly reduces the cpu load. s dadr w a iadr(23:16) a iadr(15:8) a iadr(7:0) a s dadr w a iadr(15:8) a iadr(7:0) a a iadr(7:0) a s dadr w data n p sr dadr r a sr dadr r a data n p sr dadr ra data np twd twd twd three bytes internal address two bytes internal address one byte internal address s t a r t m s b device address 0 l s b r / w a c k m s b w r i t e a c k a c k l s b a c k first word address second word address data s t o p
227 32059l?avr32?01/2012 at32uc3b to assure correct implementation, respect the following programming sequences: 19.11.1 data transmit with the peripheral dma controller 1. initialize the peripheral dma controller tx channel (memory pointers, size, etc.). 2. configure the master m ode (dadr, ckdiv, etc.). 3. start the transfer by setting the peripheral dma controller txen bit. 4. wait for the peripheral dma controller end tx flag. 5. disable the peripheral dma controller by se tting the peripheral dma controller txdis bit. 19.11.2 data receive with the peripheral dma controller 1. initialize the peripheral dma controller tx channel (memory pointers, size, etc.). 2. configure the master m ode (dadr, ckdiv, etc.). 3. start the transfer by setting the peripheral dma controller rxen bit. 4. wait for the peripheral dma controller end rx flag. 5. disable the peripheral dma controller by setting the peripheral dma controller rxdis bit.
228 32059l?avr32?01/2012 at32uc3b 19.11.3 read-write flowcharts the following flowcharts shown in figure 19-14 to figure 19-19 on page 233 give examples for read and write operations. a polling or interrupt method can be used to check the status bits. the interrupt method requires th at the interrupt enable register (ier) be configured first. figure 19-14. twi write operation with single da ta byte without internal address. set twi clock (cldiv, chdiv, ckdiv) in twi_cwgr (needed only once) set the control register: - master enable twi_cr = msen + svdis set the master mode register: - device slave address (dadr) - transfer direction bit write ==> bit mread = 0 load transmit register twi_thr = data to send read status register txrdy = 1? read status register txcomp = 1? transfer finished ye s ye s begin no no
229 32059l?avr32?01/2012 at32uc3b figure 19-15. twi write operation with single data byte and internal address begin set twi clock (cldiv, chdiv, ckdiv) in twi_cwgr (needed only once) set the control register: - master enable twi_cr = msen + svdis set the master mode register: - device slave address (dadr) - internal address size (iadrsz) - transfer direction bit write ==> bit mread = 0 load transmit register twi_thr = data to send read status register txrdy = 1? read status register txcomp = 1? transfer finished set the internal address twi_iadr = address ye s ye s no no
230 32059l?avr32?01/2012 at32uc3b figure 19-16. twi write operation with mu ltiple data byte s with or without internal address set the control register: - master enable twi_cr = msen + svdis set the master mode register: - device slave address - internal address size (if iadr used) - transfer direction bit write ==> bit mread = 0 internal address size = 0? load transmit register twi_thr = data to send read status register txrdy = 1? data to send? read status register txcomp = 1? end begin set the internal address twi_iadr = address ye s twi_thr = data to send ye s ye s ye s no no no set twi clock (cldiv, chdiv, ckdiv) in twi_cwgr (needed only once)
231 32059l?avr32?01/2012 at32uc3b figure 19-17. twi read operation with single data byte without internal address set the control register: - master enable twi_cr = msen + svdis set the master mode register: - device slave address - transfer direction bit read ==> bit mread = 1 start the transfer twi_cr = start | stop read status register rxrdy = 1? read status register txcomp = 1? end begin ye s ye s set twi clock (cldiv, chdiv, ckdiv) in twi_cwgr (needed only once) read receive holding register no no
232 32059l?avr32?01/2012 at32uc3b figure 19-18. twi read operation with single data byte and internal address set the control register: - master enable twi_cr = msen + svdis set the master mode register: - device slave address - internal address size (iadrsz) - transfer direction bit read ==> bit mread = 1 read status register txcomp = 1? end begin ye s set twi clock (cldiv, chdiv, ckdiv) in twi_cwgr (needed only once) ye s set the internal address twi_iadr = address start the transfer twi_cr = start | stop read status register rxrdy = 1? read receive holding register no no
233 32059l?avr32?01/2012 at32uc3b figure 19-19. twi read operation with mult iple data bytes with or without internal address internal address size = 0? start the transfer twi_cr = start stop the transfer twi_cr = stop read status register rxrdy = 1? last data to read but one? read status register txcomp = 1? end set the internal address twi_iadr = address ye s ye s ye s no ye s read receive holding register (twi_rhr) no set the control register: - master enable twi_cr = msen + svdis set the master mode register: - device slave address - internal address size (if iadr used) - transfer direction bit read ==> bit mread = 1 begin set twi clock (cldiv, chdiv, ckdiv) in twi_cwgr (needed only once) no read status register rxrdy = 1? ye s read receive holding register (twi_rhr) no
234 32059l?avr32?01/2012 at32uc3b 19.12 multi-master mode 19.12.1 definition more than one master may handle the bus at t he same time without data corruption by using arbitration. arbitration starts as soon as two or more master s place information on the bus at the same time, and stops (arbitration is lost) for the master th at intends to send a logical one while the other master sends a logical zero. as soon as arbitration is lost by a master, it st ops sending data and listens to the bus in order to detect a stop. when the stop is detected, the ma ster who has lost arbitration may put its data on the bus by respecting arbitration. arbitration is illustrated in figure 19-21 on page 235 . 19.12.2 different multi-master modes two multi-master modes may be distinguished: 1. twi is considered as a master only and will never be addressed. 2. twi may be either a master or a slave and may be addressed. note: arbitration is supported in both multi-master modes. 19.12.2.1 twi as master only in this mode, twi is considered as a master only (msen is always at one) and must be driven like a master with the arblst (arb itration lost) flag in addition. if arbitration is lost (arblst = 1), the pr ogrammer must reinitiate the data transfer. if the user starts a tr ansfer (ex.: dadr + start + w + write in thr) and if the bus is busy, the twi automatically waits for a stop condition on the bus to initiate the transfer (see figure 19- 20 on page 235 ). note: the state of the bus (busy or free) is not indicated in the user interface. 19.12.2.2 twi as master or slave the automatic reversal from master to slave is not supported in case of a lost arbitration. then, in the case where twi may be either a master or a slave, the programmer must manage the pseudo multi-master mode described in the steps below. 1. program twi in slave mode (sadr + ms dis + sven) and perfor m slave access (if twi is addressed). 2. if twi has to be set in master mo de, wait until txcomp flag is at 1. 3. program master mode (dadr + svdis + msen) and start the transfer (ex: start + write in thr). 4. as soon as the master mode is enabled, twi scans the bus in order to detect if it is busy or free. when the bus is considered as free, twi initiates the transfer. 5. as soon as the transfer is initiated and until a stop condition is sent, the arbitration becomes relevant and the user must monitor the arblst flag. 6. if the arbitration is lost (a rblst is set to 1), the user must program the twi in slave mode in the case where the master that won the arbitration wanted to access the twi.
235 32059l?avr32?01/2012 at32uc3b 7. if twi has to be set in slave mode, wait until txcomp flag is at 1 and then program the slave mode. note: in the case where the arbitration is lost and twi is addressed, twi will not acknowledge even if it is programmed in slave mode as soon as arblst is set to 1. then, the master must repeat sadr. figure 19-20. programmer sends data while the bus is busy figure 19-21. arbitration cases the flowchart shown in figure 19-22 on page 236 gives an example of read and write operations in multi-master mode. twck twd data sent by a master stop sent by the master start sent by the twi data sent by the twi bus is busy bus is free a transfer is programmed (dadr + w + start + write thr) transfer is initiated twi data transfer transfer is kept bus is considered as free twck bus is busy bus is free a transfer is programmed (dadr + w + start + write thr) transfer is initiated twi data transfer transfer is kept bus is considered as free data from a master data from twi s 0 s 0 0 1 1 1 arblst s 0 s 0 0 1 1 1 twd s 0 0 1 1 1 1 1 arbitration is lost twi stops sending data p s 0 1 p 0 1 1 1 1 data from the master data from the twi arbitration is lost the master stops sending data transfer is stopped transfer is programmed again (dadr + w + start + write thr) twck twd
236 32059l?avr32?01/2012 at32uc3b figure 19-22. multi-master flowchart programm the slave mode: sadr + msdis + sven svacc = 1 ? txcomp = 1 ? gacc = 1 ? decoding of the programming sequence prog seq ok ? change sadr svread = 0 ? read status register rxrdy= 0 ? read twi_rhr txrdy= 1 ? eosacc = 1 ? write in twi_thr need to perform a master access ? program the master mode dadr + svdis + msen + clk + r / w read status register arblst = 1 ? mread = 1 ? txrdy= 0 ? write in twi_thr data to send ? rxrdy= 0 ? read twi_rhr data to read? stop transfer read status register txcomp = 0 ? general call treatment ye s ye s ye s ye s ye s ye s ye s ye s ye s ye s ye s ye s ye s ye s start
237 32059l?avr32?01/2012 at32uc3b 19.13 slave mode 19.13.1 definition the slave mode is defined as a mode where the device receives the clock and the address from another device called the master. in this mode, the device never initiates and never completes the transmission (start, repeated_start and stop conditions are always provided by the master). 19.13.2 application block diagram figure 19-23. slave mode typical application block diagram 19.13.3 programming slave mode the following fields must be programmed before entering slave mode: 1. sadr (smr): the slave device address is used in order to be accessed by master devices in read or write mode. 2. msdis (cr): disable the master mode. 3. sven (cr): enable the slave mode. as the device receives the cl ock, values written in cwgr are not taken into account. 19.13.4 receiving data after a start or repeated start condition is detected and if the addres s sent by the master matches with the slave addre ss programmed in the sadr (sla ve address) field, svacc (slave access) flag is set and svread (slave read) indicates the direction of the transfer. svacc remains high until a stop condition or a repeated start is detected. when such a condition is detected, eosacc (end of slave access) flag is set. 19.13.4.1 read sequence in the case of a read sequence (svread is high), twi transfers data written in the thr (twi transmit holding register) unt il a stop condition or a repeate d_start + an address differ- ent from sadr is detected. note that at the end of the read sequence txcomp (transmission complete) flag is set and svacc reset. as soon as data is written in the thr, txrdy (transmit hold ing register ready) flag is reset, and it is set when the shift register is empty and th e sent data acknowledged or not. if the data is not acknowledged, the nack flag is set. host with twi interface twd twck lcd controller slave 1 slave 2 slave 3 rr vdd host with twi interface host with twi interface master
238 32059l?avr32?01/2012 at32uc3b note that a stop or a repeated start always follows a nack. see figure 19-24 on page 239 . 19.13.4.2 write sequence in the case of a write sequence (svread is low), the rxrdy (receive holding register ready) flag is set as soon as a character has been received in the rhr (twi receive holding register). rxrdy is reset when reading the rhr. twi continues receiving data until a stop co ndition or a repeated_start + an address dif- ferent from sadr is detected. note that at t he end of the write sequence txcomp flag is set and svacc reset. see figure 19-25 on page 239 . 19.13.4.3 clock synchronization sequence in the case where thr or rhr is not written/read in time, twi pe rforms a clock synchronization. clock stretching information is given by the sclws (clock wait state) bit. see figure 19-27 on page 241 and figure 19-28 on page 242 . 19.13.4.4 general call in the case where a general call is perfor med, gacc (general call access) flag is set. after gacc is set, it is up to the programmer to interpret the meaning of the general call and to decode the new address programming sequence. see figure 19-26 on page 240 . 19.13.4.5 peripheral dma controller as it is impossible to know the exact number of data to rece ive/send, the use of peripheral dma controller is not reco mmended in slave mode. 19.13.5 data transfer 19.13.5.1 read operation the read mode is defined as a data requirement from the master. after a start or a repeated start condition is detected, the decoding of the address starts. if the slave address (sadr) is decoded, svacc is set and svread indicates the direc- tion of the transfer. until a stop or repeated start condition is detected, twi cont inues sending data loaded in the thr register. if a stop condition or a repeated start + an address different from sadr is detected, svacc is reset. figure 19-24 on page 239 describes the write operation.
239 32059l?avr32?01/2012 at32uc3b figure 19-24. read access ordered by a master notes: 1. when svacc is low, the state of svread becomes irrelevant. 2. txrdy is reset when data has been transmitted from thr to the shift register and set when this data has been acknowledged or non acknowledged. 19.13.5.2 write operation the write mode is defined as a data transmission from the master. after a start or a repeated star t, the decoding of the addres s starts. if the slave address is decoded, svacc is set and svread indicates the direction of the transfer (svread is low in this case). until a stop or repeated start condition is detected, twi stores the received data in the rhr register. if a stop condition or a repeated start + an address different from sadr is detected, svacc is reset. figure 19-25 on page 239 describes the write operation. figure 19-25. write access ordered by a master notes: 1. when svacc is low, the state of svread becomes irrelevant. 2. rxrdy is set when data has been transmitted from the shift register to the rhr and reset when this data is read. write thr read rhr svread has to be taken into account only while svacc is active twd txrdy nack svacc svread eosvacc sadr s adr r na r a data a a data na s/sr data na p/s/sr sadr matches, twi answers with an ack sadr does not match, twi answers with a nack ack/nack from the master rxrdy read rhr svread has to be taken into account only while svacc is active twd svacc svread eosvacc sadr does not match, twi answers with a nack sadr s adr w na w a data a a data na s/sr data na p/s/sr sadr matches, twi answers with an ack
240 32059l?avr32?01/2012 at32uc3b 19.13.5.3 general call the general call is performed in order to change the address of the slave. if a general call is detected, gacc is set. after the detection of general call, it is up to the programmer to decode the commands which come afterwards. in case of a write command, the programmer has to decode the programming sequence and program a new sadr if the programming sequence matches. figure 19-26 on page 240 describes the general call access. figure 19-26. master performs a general call note: 1. this method allows the user to create an own programming sequence by choosing the pro- gramming bytes and the number of them. the programming sequence has to be provided to the master. 0000000 + w general call p s a general call reset or write dadd a new sadr data 1 a data 2 a a new sadr programming sequence txd gcacc svacc reset command = 00000110x write command = 00000100x reset after read
241 32059l?avr32?01/2012 at32uc3b 19.13.6 clock synchronization in both read and write modes, it may happen that thr/rhr buffer is not filled /emptied before the emission/reception of a new character. in this case, to avoid sending/receiving undesired data, a clock stretching mechanism is implemented. 19.13.6.1 clock synchronization in read mode the clock is tied low if the shif t register is empty and if a stop or repeated start condition was not detected. it is tied low until the shift register is loaded. figure 19-27 on page 241 describes the clock synchronization in read mode. figure 19-27. clock synchronization in read mode notes: 1. txrdy is reset when data has been written in the th to the shift register and set when this data has been acknowledged or non acknowledged. 2. at the end of the read sequence, txcomp is set after a stop or after a repeated_start + an address different from sadr. 3. sclws is automatically set when the clock synchronization mechanism is started. data 1 the clock is stretched after the ack, the state of twd is undefined during clock stretching sclws svacc svread txrdy twck twi_thr txcomp the data is memorized in twi_thr until a new value is written twi_thr is transmitted to the shift register ack or nack from the master data 0 data 0 data 2 1 2 1 clock is tied low by the twi as long as thr is empty s sadr s r data 0 a a data 1 a data 2 na s xxxxxxx 2 write thr as soon as a start is detected
242 32059l?avr32?01/2012 at32uc3b 19.13.6.2 clock synchronization in write mode the clock is tied low if the shift register an d the rhr is full. if a stop or repeated_start condition was not detected, it is tied low until rhr is read. figure 19-28 on page 242 describes the clock synchronization in read mode. figure 19-28. clock synchronization in write mode notes: 1. at the end of the read sequence, txcomp is set after a stop or after a repeated_start + an address different from sadr. 2. sclws is automatically set when the clock synchronization mechanism is started and automatically reset when the mecha- nism is finished. rd data0 rd data1 rd data2 svacc svread rxrdy sclws txcomp data 1 data 2 scl is stretched on the last bit of data1 as soon as a start is detected twck twd twi_rhr clock is tied low by the twi as long as rhr is full data0 is not read in the rhr adr s sadr w a data 0 a a data 2 data 1 s na
243 32059l?avr32?01/2012 at32uc3b 19.13.7 reversal after a repeated start 19.13.7.1 reversal of read to write the master initiates the communication by a read command and finishes it by a write command. figure 19-29 on page 243 describes the repeated start + reversal from read to write mode. figure 19-29. repeated start + reversal from read to write mode note: 1. txcomp is only set at the end of the transm ission because after the repeated start, sadr is detected again. 19.13.7.2 reversal of write to read the master initiates the communication by a write command and finishes it by a read com- mand. figure 19-30 on page 243 describes the repeated start + reversal from write to read mode. figure 19-30. repeated start + reversal from write to read mode notes: 1. in this case, if thr has not been written at the end of the read command, the clock is automatically stretched before t he ack. s sadr r a data 0 a data 1 sadr sr na w a data 2 a data 3 a p cleared after read data 0 data 1 data 2 data 3 svacc svread twd twi_thr twi_rhr eosacc txrdy rxrdy txcomp as soon as a start is detected s sadr w a data 0 a data 1 sadr sr a r a data 2 a data 3 n a p cleared after read data 0 data 2 data 3 data 1 txcomp txrdy rxrdy as soon as a start is detected read twi_rhr svacc svread twd twi_rhr twi_thr eosacc
244 32059l?avr32?01/2012 at32uc3b 2. txcomp is only set at the end of the transmission because after the repeated start, sadr is detected again. 19.13.8 read write flowcharts the flowchart shown in figure 19-31 on page 244 gives an example of read and write operations in slave mode. a polling or interr upt method can be used to check the status bits. the interrupt method requires that the interrupt enabl e register (ier) be configured first. figure 19-31. read write flowchart in slave mode set the slave mode: sadr + msdis + sven svacc = 1 ? txcomp = 1 ? gacc = 1 ? decoding of the programming sequence prog seq ok ? change sadr svread = 0 ? read status register rxrdy= 0 ? read twi_rhr txrdy= 1 ? eosacc = 1 ? write in twi_thr end general call treatment
245 32059l?avr32?01/2012 at32uc3b 19.14 user interface table 19-4. twi user interface offset register register name access reset 0x00 control register cr write-only n / a 0x04 master mode register mmr read/write 0x00000000 0x08 slave mode register smr read/write 0x00000000 0x0c internal address register iadr read/write 0x00000000 0x10 clock waveform generator register cwgr read/write 0x00000000 0x20 status register sr read-only 0x0000f009 0x24 interrupt enable register ier write-only n / a 0x28 interrupt disable register idr write-only n / a 0x2c interrupt mask register imr read-only 0x00000000 0x30 receive holding register rhr read-only 0x00000000 0x34 transmit holding register thr write-only 0x00000000
246 32059l?avr32?01/2012 at32uc3b 19.14.1 control register name: cr access: write-only offset: 0x00 reset value: 0x00000000 ? swrst: software reset 0 = no effect. 1 = equivalent to a system reset. ? svdis: twi slave mode disabled 0 = no effect. 1 = the slave mode is disabled. the shifter and holding characters (if it contains data) are transmitted in case of read operat ion. in write operation, the character being transferr ed must be completely received before disabling. ? sven: twi slave mode enabled 0 = no effect. 1 = if svdis = 0, the slave mode is enabled. switching from master to slave mode is only permitted when txcomp = 1. ? msdis: twi master mode disabled 0 = no effect. 1 = the master mode is disabled, all pending data is transmitt ed. the shifter and holding characters (if it contains data) are transmitted in case of write operation. in read operation, the character being transferred must be completely received before disabling. ? msen: twi master mode enabled 0 = no effect. 1 = if msdis = 0, the master mode is enabled. switching from slave to master mode is only permitted when txcomp = 1. ? stop: send a stop condition 0 = no effect. 1 = stop condition is sent just after completing the current byte transmission in master read mode. ? start: send a start condition 0 = no effect. 1 = a frame beginning with a start bit is transmitted a ccording to the features defined in the mode register. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 swrst ? svdis sven msdis msen stop start - in single data byte master read, the start and stop must both be set. - in multiple data bytes master read, the stop must be set after the last data received but one. - in master read mode, if a nack bit is received, the stop is automatically performed. - in multiple data write operation, when both thr and shift register are empty, a stop condition is automatically sent.
247 32059l?avr32?01/2012 at32uc3b this action is necessary when the twi peripheral wants to read da ta from a slave. when configured in master mode with a write operation, a frame is sent as soon as the user writes a character in the transmit holding register (thr).
248 32059l?avr32?01/2012 at32uc3b 19.14.2 master mode register name: mmr access: read-write offset: 0x04 reset value: 0x00000000 ? dadr: device address the device address is used to access slave devices in read or write mode. those bits are only used in master mode. ? mread: master read direction 0 = master write direction. 1 = master read direction. ? iadrsz: internal device address size 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ?dadr 15 14 13 12 11 10 9 8 ???mread?? iadrsz 76543210 ???????? iadrsz[9:8] description 0 0 no internal device address 0 1 one-byte internal device address 1 0 two-byte internal device address 1 1 three-byte internal device address
249 32059l?avr32?01/2012 at32uc3b 19.14.3 slave mode register name: smr access: read-write offset: 0x08 reset value: 0x00000000 ? sadr: slave address the slave device address is used in slave mode in order to be accessed by master devices in read or write mode. sadr must be programmed before enabling the slave mode or after a general call. writes at other times have no effect. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ?sadr 15 14 13 12 11 10 9 8 ?????? 76543210 ????????
250 32059l?avr32?01/2012 at32uc3b 19.14.4 internal address register name: iadr access: read-write offset: 0x0c reset value: 0x00000000 ? iadr: internal address 0, 1, 2 or 3 bytes depending on iadrsz. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 iadr 15 14 13 12 11 10 9 8 iadr 76543210 iadr
251 32059l?avr32?01/2012 at32uc3b 19.14.5 clock waveform generator register name: cwgr access: read-write offset: 0x10 reset value: 0x00000000 cwgr is only used in master mode. ? ckdiv: clock divider the ckdiv is used to increase both scl high and low periods. ? chdiv: clock high divider the scl high period is defined as follows: ? cldiv: clock low divider the scl low period is defined as follows: 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ckdiv 15 14 13 12 11 10 9 8 chdiv 76543210 cldiv t high chdiv ( 2 ckdiv () 4 ) + t clk_twi = t low cldiv ( 2 ckdiv () 4 ) + t clk_twi =
252 32059l?avr32?01/2012 at32uc3b 19.14.6 status register name: sr access: read-only offset: 0x20 reset value: 0x0000f009 ? eosacc: end of slave access (clear on read) this bit is only used in slave mode. 0 = a slave access is being performing. 1 = the slave access is finished. end of slave acce ss is automatically set as soon as svacc is reset. eosacc behavior can be seen in figure 19-29 on page 243 and figure 19-30 on page 243 ? sclws: clock wait state (automatically set / reset) this bit is only used in slave mode. 0 = the clock is not stretched. 1 = the clock is stretched. thr / rhr buffer is not filled / em ptied before the emission / reception of a new character. sclws behavior can be seen in figure 19-27 on page 241 and figure 19-28 on page 242 . ? arblst: arbitration lost (clear on read) this bit is only used in master mode. 0 = arbitration won. 1 = arbitration lost. another master of the twi bus has won the multi-master arbitration. txcomp is set at the same time. ? nack: not acknowledged (clear on read) nack used in master mode: 0 = each data byte has been correctly received by the far-end side twi slave component. 1 = a data byte has not been acknowledged by the slave component. set at the same time as txcomp. nack used in slave read mode: 0 = each data byte has been correctly received by the master. 1 = in read mode, a data byte has not been acknowledged by t he master. when nack is set the programmer must not fill thr even if txrdy is set, because it means that the ma ster will stop the data transfer or re initiate it. note that in slave write mode all data are acknowledged by the twi. ? ovre: overrun error (clear on read) this bit is only used in slave mode. 0 = rhr has not been loaded while rxrdy was set 1 = rhr has been loaded while rxrdy was set. reset by read in sr when txcomp is set. ? gacc: general call access (clear on read) this bit is only used in slave mode. 0 = no general call has been detected. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ????eosaccsclwsarblstnack 76543210 ? ovre gacc svacc svread txrdy rxrdy txcomp
253 32059l?avr32?01/2012 at32uc3b 1 = a general call has been detected. after the detection of general call, the programmer decoded the commands that follow and the programming sequence. gacc behavior can be seen in figure 19-26 on page 240 . ? svacc: slave access (automatically set / reset) this bit is only used in slave mode. 0 = twi is not addressed. svacc is automatically cleared after a nack or a stop condition is detected. 1 = indicates that the address decoding sequence has matched (a master has sent sadr). svacc remains high until a nack or a stop condition is detected. svacc behavior can be seen in figure 19-24 on page 239 , figure 19-25 on page 239 , figure 19-29 on page 243 and figure 19-30 on page 243 . ? svread: slave read (automatically set / reset) this bit is only used in slave mode. when svacc is low (no slave access has been detected) svread is irrelevant. 0 = indicates that a write access is performed by a master. 1 = indicates that a read access is performed by a master. svread behavior can be seen in figure 19-24 on page 239 , figure 19-25 on page 239 , figure 19-29 on page 243 and figure 19-30 on page 243 . ? txrdy: transmit holding register ready (automatically set / reset) txrdy used in master mode: 0 = the transmit holding register has not been transferred in to shift register. set to 0 when writing into thr register. 1 = as soon as a data byte is transferred from thr to internal sh ifter or if a nack error is detected, txrdy is set at the same time as txcomp and nack. txrdy is also set when msen is set (enable twi). txrdy behavior in master mode can be seen in figure 19-8 on page 223 . txrdy used in slave mode: 0 = as soon as data is written in the thr, until this data has been transmitted and acknowledged (ack or nack). 1 = it indicates that the thr is empty and that data has been transmitted and acknowledged. if txrdy is high and if a nack has been detected, the trans mission will be stopped. thus when trdy = nack = 1, the programmer must not fill thr to avoid losing it. txrdy behavior in slave mode can be seen in figure 19-24 on page 239 , figure 19-27 on page 241 , figure 19-29 on page 243 and figure 19-30 on page 243 . ? rxrdy: receive holding register ready (automatically set / reset) 0 = no character has been received since the last rhr read operation. 1 = a byte has been received in the rhr since the last read. rxrdy behavior in master mode can be seen in figure 19-10 on page 224 . rxrdy behavior in slave mod e can be seen in figure 19-25 on page 239 , figure 19-28 on page 242 , figure 19-29 on page 243 and figure 19-30 on page 243 . ? txcomp: transmission completed (automatically set / reset) txcomp used in master mode: 0 = during the length of the current frame. 1 = when both holding and shifter registers are empty and stop condition has been sent. txcomp behavior in master mode can be seen in figure 19-8 on page 223 and in figure 19-10 on page 224 . txcomp used in slave mode: 0 = as soon as a start is detected. 1 = after a stop or a repeated start + an address different from sadr is detected. txcomp behavior in slave mode can be seen in figure 19-27 on page 241 , figure 19-28 on page 242 , figure 19-29 on page 243 and figure 19-30 on page 243 .
254 32059l?avr32?01/2012 at32uc3b 19.14.7 interrupt enable register name: ier access: write-only offset: 0x24 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ????eosaccscl_wsarblstnack 76543210 ? ovre gacc svacc ? txrdy rxrdy txcomp
255 32059l?avr32?01/2012 at32uc3b 19.14.8 interrupt disable register name: idr access: write-only offset: 0x28 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ????eosaccscl_wsarblstnack 76543210 ? ovre gacc svacc ? txrdy rxrdy txcomp
256 32059l?avr32?01/2012 at32uc3b 19.14.9 interrupt mask register name: imr access: read-only offset: 0x2c reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. a bit in this register is cleared when the corresponding bit in idr is written to one. a bit in this register is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ????eosaccscl_wsarblstnack 76543210 ? ovre gacc svacc ? txrdy rxrdy txcomp
257 32059l?avr32?01/2012 at32uc3b 19.14.10 receive holding register name: rhr access: read-only offset: 0x30 reset value: 0x00000000 ? rxdata: master or slave receive holding data 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 rxdata
258 32059l?avr32?01/2012 at32uc3b 19.14.11 transmit holding register name: thr access: read-write offset: 0x34 reset value: 0x00000000 ? txdata: master or slave transmit holding data 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 txdata
259 32059l?avr32?01/2012 at32uc3b 20. synchronous serial controller (ssc) rev: 3.1.0.2 20.1 features ? provides serial synchronous communication lin ks used in audio and telecom applications ? independent receiver and transmitter, common clock divider ? interfaced with two peripheral dma controlle r channels to reduce processor overhead ? configurable frame sync and data length ? receiver and transmitter can be configured to start automatically or on detection of different events on the frame sync signal ? receiver and transmitter include a data signal, a clock signal and a frame synchronization signal 20.2 overview the synchronous serial contro ller (ssc) provides a synchronous communication link with external devices. it supports m any serial synchronous commun ication protocol s generally used in audio and telecom applications such as i2s, short frame sync, long frame sync, etc. the ssc consists of a receiver, a transmitter, and a common clock divider. both the receiver and the transmitter interface with three signals: ? the tx_data/rx_data signal for data ? the tx_clock/rx_clock signal for the clock ? the tx_frame_sync/rx_frame_sync si gnal for the frame synchronization the transfers can be programmed to start automatica lly or on different events detected on the frame sync signal. the ssc?s high-level of programma bility and its two dedicated pe ripheral dma controller chan- nels of up to 32 bits permit a continuous hi gh bit rate data transfer without processor intervention. featuring connection to two peripheral dma cont roller channels, the ss c permits interfacing with low processor over head to the following: ? codec?s in master or slave mode ? dac through dedicated serial interface, particularly i2s ? magnetic card reader
260 32059l?avr32?01/2012 at32uc3b 20.3 block diagram figure 20-1. ssc block diagram 20.4 application block diagram figure 20-2. ssc application block diagram ssc interface peripheral dma controller peripheral bus bridge hi gh speed bus peripheral bus power manager clk_ssc i/o controller interrupt control ssc interrupt tx_frame_sync rx_frame_sync tx_clock rx_clock rx_data tx_data test management line interface interrupt management frame management time slot management ssc power management codec serial audio os or rtos driver
261 32059l?avr32?01/2012 at32uc3b 20.5 i/o lines description 20.6 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 20.6.1 i/o lines the pins used for interfacing the compliant external devices may be multiplexed with i/o lines. before using the ssc receiver, the i/o controller must be configured to dedicate the ssc receiver i/o lines to the ssc peripheral mode. before using the ssc transmitter, the i/o contro ller must be configured to dedicate the ssc transmitter i/o lines to the ssc peripheral mode. 20.6.2 clocks the clock for the ssc bus interface (clk_ssc) is generated by the power manager. this clock is enabled at reset, and can be disabled in th e power manager. it is recommended to disable the ssc before disabling the clock, to avoi d freezing the ssc in an undefined state. 20.6.3 interrupts the ssc interrupt request line is connected to the interrupt controller. using the ssc interrupt requires the interrupt controller to be programmed first. 20.7 functional description this chapter contains the functional description of the following: ssc functional block, clock management, data framing format, start, transmitter, receiver, and frame sync. the receiver and the transmitter operate separat ely. however, they can work synchronously by programming the receiver to use the transmit clo ck and/or to start a data transfer when transmis- sion starts. alternatively, this can be done by programming the transmitter to use the receive clock and/or to start a data transfer when recept ion starts. the transmitter and the receiver can be programmed to operate with the clock signals provided on either the tx_clock or rx_clock pins. this allows the ssc to suppor t many slave-mode data transfers. the maxi- mum clock speed allowed on the tx_clock and rx_clock pins is clk_ssc divided by two. table 20-1. i/o lines description pin name pin description type rx_frame_sync receiver frame synchro input/output rx_clock receiver clock input/output rx_data receiver data input tx_frame_sync transmitter frame synchro input/output tx_clock transmitter clock input/output tx_data transmitter data output
262 32059l?avr32?01/2012 at32uc3b figure 20-3. ssc functional block diagram 20.7.1 clock management the transmitter clock can be generated by: ? an external clock received on the tx_clock pin ? the receiver clock ? the internal clock divider the receiver clock can be generated by: ? an external clock received on the rx_clock pin ? the transmitter clock ? the internal clock divider furthermore, the transmitter block can generate an external clock on the tx_clock pin, and the receiver block can generate an ex ternal clock on the rx_clock pin. this allows the ssc to support many master and slave mode data transfers. clock divider user interface peripheral bus clk_ssc interrupt control start selector receive shift register receive holding register receive sync holding register dma interrupt controller rx_frame_sync rx_data rx_clock frame sync controller clock output controller receive clock controller transmit holding register transmit sync holding register transmit shift register frame sync controller clock output controller transmit clock controller start selector tx_frame_sync rx_frame_sync tx_clock input transmitter tx_dma load shift rx clock tx clock tx_clock tx_frame_sync tx_data receiver rx clock rx_clock input tx clock tx_frame_sync rx_frame_sync rx_dma load shift
263 32059l?avr32?01/2012 at32uc3b 20.7.1.1 clock divider figure 20-4. divided clock block diagram the peripheral clock divider is determined by th e 12-bit clock divider field (its maximal value is 4095) in the clock mode register (cmr.div), allo wing a peripheral clock division by up to 8190. the divided clock is provided to both the receiver and transmitter. when this field is written to zero, the clock divider is not used and remains inactive. when cmr.div is written to a value equal to or greater than one, the divided clock has a fre- quency of clk_ssc divided by two times cmr. div. each level of the divided clock has a duration of the peripheral clock multiplied by cmr.div. this ens ures a 50% duty cycle for the divided clock regardless of whether the cmr.div value is even or odd. figure 20-5. divided clock generation 20.7.1.2 transmitter clock management the transmitter clock is generated from the receiver clock, the divider clock, or an external clock scanned on the tx_clock pin. the transmitter cl ock is selected by wr iting to the transmit clock selection field in the trans mit clock mode register (tcm r.cks). the transmit clock can table 20-2. range of clock divider maximum minimum clk_ssc / 2 clk_ssc / 8190 cmr / 2 clk_ssc divided clock 12-bit counter clock divider clk_ssc divided clock div = 1 clk_ssc divided clock div = 3 divided clock frequency = clk_ssc/2 divided clock frequency = clk_ssc/6
264 32059l?avr32?01/2012 at32uc3b be inverted independently by writing a one to the transmit clock inversion bit in tcmr (tcmr.cki). the transmitter can also drive the tx_clock pin continuously or be limited to the actual data transfer, depending on the transmit clock output mode selection field in the tcmr register (tcmr.cko). the tcmr.cki bit has no effect on the clock outputs. writing 0b10 to the tcmr.cks field to select tx_clock pin and 0b001 to the tcmr.cko field to select continuous transmit clock can lead to unpredictable results. figure 20-6. transmitter clock management 20.7.1.3 receiver clock management the receiver clock is generated from the transmitte r clock, the divider clock, or an external clock scanned on the rx_clock pin. the receive clock is selected by writin g to the receive clock selection field in the receive clock mode re gister (rcmr.cks). the receive clock can be inverted independently by writing a one to the receive clock inversion bit in rcmr (rcmr.cki). the receiver can also drive the rx_clock pin co ntinuously or be limited to the actual data transfer, depending on the receive clock output mode selection field in the rcmr register (rcmr.cko). the rcmr.ck i bit has no effect on the clock outputs. writing 0b10 to the rcmr.cks field to sele ct rx_clock pin and 0b001 to the rcmr.cko field to select continuous receive cl ock can lead to unpredictable results. tx_clock receiver clock divider clock cko data transfer tri-state controller inv mux cks mux tri-state controller cki ckg transmitter clock clock output
265 32059l?avr32?01/2012 at32uc3b figure 20-7. receiver clock management 20.7.1.4 serial clock ratio considerations the transmitter and the receiver can be programme d to operate with the clock signals provided on either the tx_clock or rx_clock pins. th is allows the ssc to support many slave-mode data transfers. in this case, the maximum clock speed allowed on the rx_clock pin is: ? clk_ssc divided by two if rx_frame_sync is input. ? clk_ssc divided by three if rx_frame_sync is output. in addition, the maximum clock spe ed allowed on the tx_clock pin is: ? clk_ssc divided by six if tx_frame_sync is input. ? clk_ssc divided by two if tx_frame_sync is output. 20.7.2 transmitter operations a transmitted frame is triggered by a start event and can be followed by synchronization data before data transmission. the start event is configured by writing to the tcmr register. see section 20.7.4 . the frame synchronization is configured by writing to the transmit frame mode register (tfmr). see section 20.7.5 . to transmit data, the transmitter uses a shift re gister clocked by the tr ansmitter clock signal and the start mode selected in the tcmr register. data is written by the user to the transmit holding register (thr) then transferred to the shift register according to the data format selected. when both the thr and the transmit shift registers are empty, the transmit empty bit is set in the status register (sr. txempty). when the thr register is transferred in the transmit shift register, the transmit ready bit is set in the sr register (sr.txready) and additional data can be loaded in the thr register. divider clock rx_clock transmitter clock mux tri-state controller cko data transfer inv mux cki tri-state controller ckg receiver clock clock output cks
266 32059l?avr32?01/2012 at32uc3b figure 20-8. transmitter block diagram 20.7.3 receiver operations a received frame is triggered by a start event and can be followed by synchronization data before data transmission. the start event is configured by writing to the rcmr register. see section 20.7.4 . the frame synchronization is configured by wr iting to the receive frame mode register (rfmr). see section 20.7.5 . the receiver uses a shift regi ster clocked by the receiver clock signal and the start mode selected in the rcmr register. the data is transfe rred from the shift register depending on the data format selected. when the receiver shift register is full, the ssc transfers this da ta in the receive holding regis- ter (rhr), the receive ready bit is set in the sr register (sr.rxready) and the data can be read in the rhr register. if another tr ansfer occurs before a read of the rhr register , the receive overrun bit is set in the sr register (sr. ovrun) and the receiver shift register is trans- ferred to the rhr register. tfmr.datdef tfmr.msbf 0 1 transmit shift register 01 thr tshr tfmr.fslen tcmr.sttdly tfmr.fsden tfmr.datnb cr.txen cr.txdis sr.txen tx_data tfmr.datlen tcmr.sttdly tfmr.fsden start selector rx_frame_sync tx_frame_sync transmitter clock
267 32059l?avr32?01/2012 at32uc3b figure 20-9. receiver block diagram 20.7.4 start the transmitter and receiver can both be progra mmed to start their operations when an event occurs, respectively in the transmit start selection field of the tcmr register (tcmr.start) and in the receive start selection fiel d of the rcmr register (rcmr.start). under the following conditions the start event is independently programmable: ? continuous: in this case, the transmission star ts as soon as a word is written to the thr register and the reception starts as soon as the receiver is enabled ? synchronously with the transmitter/receiver ? on detection of a falling/rising e dge on tx_frame_sync/rx_frame_sync ? on detection of a low/high leve l on tx_frame_sync/rx_frame_sync ? on detection of a level change or an edge on tx_frame_sync/rx_frame_sync a start can be programmed in the same manner on either side of the transmit/receive clock mode register (tcmr/rcmr). thus, the start could be on tx_frame_sync (transmit) or rx_frame_sync (receive). moreover, the receiver can start when data is dete cted in the bit stream with the compare func- tions. see section 20.7.6 for more details on receive compare modes. detection on tx_frame_sync input/output is done by the transmit frame sync output selection field in the tfmr register (tfmr. fsos). similarly, detection on rx_frame_sync input/output is done by the receive frame output sync selection field in the rfmr register (rfmr.fsos). divider clock rx_clock transmitter clock mux tri-state controller cko data transfer inv mux cki tri-state controller ckg receiver clock clock output cks
268 32059l?avr32?01/2012 at32uc3b figure 20-10. transmit start mode figure 20-11. receive pulse/ed ge start modes xb0b1 b1 b0 b0 b1 b1 b0 b0 b1 b0 b1 b0 b1 b1 b0 x x x x x tx_data (output) start= any edge on tx_frame_sync tx_data (output) start= level change on tx_frame_sync tx_data (output) start= rising edge on tx_frame_sync tx_data (output) start= falling edge on tx_frame_sync tx_data (output) start= high level on tx_frame_sync tx_data (output) start= low level on tx_frame_sync tx_frame_sync (input) tx_clock (input) sttdly sttdly sttdly sttdly sttdly sttdly rx_clock rx_frame_sync (input) rx_data (input) start = high level on rx_frame_sync rx_data (input) start = falling edge on rx_frame_sync rx_data (input) start = rising edge on rx_frame_sync rx_data (input) start = level change on rx_frame_sync rx_data (input) start = any edge on rx_frame_sync rx_data (input) start = low level on rx_frame_sync x x x x x xb0 b0 b0 b0 b0 b0 b0 b1 b1 b1 b1 b1 b1 b1 sttdly sttdly sttdly sttdly sttdly sttdly
269 32059l?avr32?01/2012 at32uc3b 20.7.5 frame sync the transmitter and receiver frame synchro pins, tx_frame_sync and rx_frame_sync, can be programmed to generate different kinds of frame synchronization signals. the rfmr.fsos and tfmr.fsos fields are used to select the required waveform. ? programmable low or high levels during data transfer are supported. ? programmable high levels before the start of data transfers or toggling are also supported. if a pulse waveform is selected , in reception, the receive fram e sync length high part and the receive frame sync length fields in the rfmr register (rfmr.fslenhi and rfmr.fslen) define the length of the pulse, from 1 bit time up to 256 bit time. similarly, in transmission, the transmit frame sync length high part and the transmit frame sync length fields in the tfmr register ( tfmr.fslenhi and tfmr.fslen) define the length of the pulse, from 1 bit up to 256 bit time. the periodicity of the rx_frame_sync and tx _frame_sync pulse outputs can be config- ured respectively through the receive period divider selection field in the rcmr register (rcmr.period) and the transmit period divi der selection field in the tcmr register (tcmr.period). 20.7.5.1 frame sync data frame sync data transmits or receives a specific tag during the frame sync signal. during the frame sync signal, the receiver can sample the rx_data line and store the data in the receive sync holding register (rshr) and the transmitter can tr ansfer the transmit sync holding register (tshr) in the shifter register. the data length to be sampled in reception during the frame sync signal shall be written to the rfmr.fslenhi and rf mr.fslen fields. the data length to be shifted out in transmission during the frame sync signal shall be written to the tfmr.fslenhi and tfmr.fslen fields. concerning the receive frame sync data operation, if the frame sync length is equal to or lower than the delay between the start event and the actual data reception, the data sampling operation is performed in the rshr through the receive shift register. the transmit frame sync operation is performed by the transmitter only if the frame sync data enable bit in tfmr register (tfmr.fsden) is wr itten to one. if the frame sync length is equal to or lower than the delay between the start ev ent and the actual data transmission, the normal transmission has priority and the data contained in the tshr is transferred in the transmit regis- ter, then shifted out. 20.7.5.2 frame sync edge detection the frame sync edge detection is configured by writing to the frame sync edge detection bit in the rfmr/tfmr registers (rfmr.fsedge and tfmr.fsedge). this sets the receive sync reception pulse length ((16 fslenhi ) fslen 1) receive clock periods ++ = transmission pulse length ((16 fslenhi ) fslen 1) transmit clock periods ++ =
270 32059l?avr32?01/2012 at32uc3b and transmit sync bits in t he sr register (sr.rxsyn and sr.txsyn) on fram e synchro edge detection (signals rx_fra me_sync/tx_frame_sync). 20.7.6 receive compare modes figure 20-12. receive compare modes 20.7.6.1 compare functions compare 0 can be one start event of the receiver. in this case, the receiver compares at each new sample the last {rfmr.fs lenhi, rfmr.fslen} bits received to the {rfmr.fslenhi, rfmr.fslen} lower bits of the data contained in the receive compare 0 register (rc0r). when this start event is selected, the user can program the receiver to start a new data transfer either by writing a new compare 0, or by rece iving continuously until compare 1 occurs. this selection is done with the receive stop sele ction bit in the rcmr register (rcmr.stop). 20.7.7 data framing format the data framing format of both the transmitter and the receiver are programmable through the tfmr, tcmr, rfmr, and rcmr registers. in eith er case, the user can independently select: ? the event that starts the data transfer (rcmr.start and tcmr.start) ? the delay in number of bit periods betwee n the start event and the first data bit (rcmr.sttdly and tcmr.sttdly) ? the length of the data (rfm r.datlen and tfmr.datlen) ? the number of data to be transferred for each start event (rfmr.datnb and tfmr.datlen) ? the length of synchronization transferre d for each start event (rfmr.fslenhi, rfmr.fslen, tfmr.fsl enhi, and tfmr.fslen) ? the bit sense: most or lowest signific ant bit first (rfmr.msbf and tfmr.msbf) additionally, the transmitter can be used to tr ansfer synchronization and select the level driven on the tx_data pin while not in data transfer oper ation. this is done re spectively by writing to the frame sync data enable and the data default value bits in the tfmr register (tfmr.fsden and tfmr.datdef). rx_data (input) rx_clock cmp0 cmp1 cmp2 cmp3 start {fslenhi,fslen} up to 256 bits (4 in this example) sttdly ignored datlen b2 b0 b1 table 20-3. data framing format registers transmitter receiver bi t/field length comment tcmr rcmr period up to 512 frame size tcmr rcmr start start selection tcmr rcmr sttdly up to 255 size of transmit start delay
271 32059l?avr32?01/2012 at32uc3b figure 20-13. transmit and receive frame format in edge/pulse start modes note: example of input on falling edge of tx_frame_sync/rx_frame_sync. figure 20-14. transmit frame format in continuous mode note: sttdly is written to zero. in this example, thr is loaded twice. fsden value has no effect on the transmission. syncdata cannot be output in continuous mode. tfmr rfmr datnb up to 16 number of words transmitted in frame tfmr rfmr datlen up to 32 size of word tfmr rfmr {fslenhi,fslen} up to 256 size of synchro data register tfmr rfmr msbf most significant bit first tfmr fsden enable send tshr tfmr datdef data default value ended table 20-3. data framing format registers transmitter receiver bi t/field length comment datnb datlen data data data data data data default default sync data sync data ignored from datdef start from datdef datlen to rhr to rhr from thr from thr from thr from thr from datdef from datdef ignored default default sync data to rshr from tshr fslen start tx_frame_sync / rx_frame_sync tx_data (if fsden = 1) tx_data (if fsden = 0) rx_data sttdly sync data period (1) start data data datlen from thr datlen tx_data start: 1. txempty set to one 2. write into the thr from thr default
272 32059l?avr32?01/2012 at32uc3b figure 20-15. receive frame format in continuous mode note: sttdly is written to zero. 20.7.8 loop mode the receiver can be programmed to receive transm issions from the transmitter. this is done by writing a one to the loop mode bit in rfmr register (rfmr.loop). in this case, rx_data is connected to tx_data, rx_frame_sync is connected to tx_frame_sync and rx_clock is connected to tx_clock. 20.7.9 interrupt most bits in the sr register have a corres ponding bit in interrupt management registers. the ssc can be programmed to generate an interrupt when it detects an event. the interrupt is controlled by writing to the inte rrupt enable register (ier) and interrupt disable register (idr). these registers enable and disable, respective ly, the corresponding interrupt by setting and clearing the corresponding bit in the interrupt mask register (imr), which controls the genera- tion of interrupts by asserting the ssc interrupt line connected to the interrupt controller. figure 20-16. interrupt bl ock diagram data data to rhr to rhr datlen datlen rx_data start = enable receiver im r ier idr clear set interrupt control ssc interrupt txrdy txempty txsync transmitter receiver rxrdy ovrun rxsync
273 32059l?avr32?01/2012 at32uc3b 20.8 ssc application examples the ssc can support several serial communica tion modes used in audio or high speed serial links. some standard applications are shown in t he following figures. all se rial link applications supported by the ssc are not listed here. figure 20-17. audio application block diagram figure 20-18. codec application block diagram clock sck word select ws data sd msb left channel lsb msb right channel data sd word select ws clock sck ssc tx_clock tx_frame_sync tx_data rx_data rx_frame_sync rx_clock i2s receiver ssc serial data clock (sclk) frame sync (fsync) serial data out serial data in serial data clock (sclk) frame sync (fsync) serial data out serial data in dstart dend first time slot codec tx_clock tx_frame_sync tx_data rx_data rx_frame_sync rx_clock
274 32059l?avr32?01/2012 at32uc3b figure 20-19. time slot application block diagram codec first time slot codec second time slot data in data out fsync sclk serial data clock (sclk) frame sync (fsync) serial data out serial data in dstart first time slot second time slot dend ssc tx_clock tx_frame_sync tx_data rx_data rx_frame_sync rx_clock
275 32059l?avr32?01/2012 at32uc3b 20.9 user interface table 20-4. ssc register memory map offset register register name access reset 0x00 control register cr write-only 0x00000000 0x04 clock mode register cmr read/write 0x00000000 0x10 receive clock mode register rcmr read/write 0x00000000 0x14 receive frame mode register rfmr read/write 0x00000000 0x18 transmit clock mode register tcmr read/write 0x00000000 0x1c transmit frame mode register tfmr read/write 0x00000000 0x20 receive holding register rhr read-only 0x00000000 0x24 transmit holding register thr write-only 0x00000000 0x30 receive synchronization holding register rshr read-only 0x00000000 0x34 transmit synchronization holding register tshr read/write 0x00000000 0x38 receive compare 0 register rc0r read/write 0x00000000 0x3c receive compare 1 register rc1r read/write 0x00000000 0x40 status register sr read-only 0x000000cc 0x44 interrupt enable register ier write-only 0x00000000 0x48 interrupt disable register idr write-only 0x00000000 0x4c interrupt mask register imr read-only 0x00000000
276 32059l?avr32?01/2012 at32uc3b 20.9.1 control register name: cr access type: write-only offset: 0x00 reset value: 0x00000000 ? swrst: software reset 1: writing a one to this bit will perform a software reset. this software reset has priority on any other bit in cr. 0: writing a zero to this bit has no effect. ? txdis: transmit disable 1: writing a one to this bit will disable the transmission. if a character is currently being transmitted, the disable occurs a t the end of the current character transmission. 0: writing a zero to this bit has no effect. ? txen: transmit enable 1: writing a one to this bit will enable the transmission if the txdis bit is not written to one. 0: writing a zero to this bit has no effect. ? rxdis: receive disable 1: writing a one to this bit will disable the reception. if a character is currently being received, the disable occurs at the end of current character reception. 0: writing a zero to this bit has no effect. ? rxen: receive enable 1: writing a one to this bit will enables the reception if the rxdis bit is not written to one. 0: writing a zero to this bit has no effect. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 swrst-----txdistxen 76543210 ------rxdisrxen
277 32059l?avr32?01/2012 at32uc3b 20.9.2 clock mode register name: cmr access type: read/write offset: 0x04 reset value: 0x00000000 ? div[11:0]: clock divider the divided clock equals the clk_ssc divided by two times div. the maximum bit rate is clk_ssc/2. the minimum bit rate is clk_ssc/(2 x 4095) = clk_ssc/8190. the clock divider is not active when div equals zero. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ---- div[11:8] 76543210 div[7:0] divided clock clk_ssc ( ? div 2) =
278 32059l?avr32?01/2012 at32uc3b 20.9.3 receive clock mode register name: rcmr access type: read/write offset: 0x10 reset value: 0x00000000 ? period: receive period divider selection this field selects the divider to apply to the selected re ceive clock in order to generate a periodic frame sync signal. if equal to zero, no signal is generated. if not equal to zero, a signal is generated each 2 x (period+1) receive clock periods. ? sttdly: receive start delay if sttdly is not zero, a delay of sttdly clock cycles is inserted between the start event and the actual start of reception. when the receiver is programmed to start synchronously with the transmitter, the delay is also applied. note: it is very important that sttdly be written carefully. if sttdly must be written, it should be done in relation to receiv e sync data reception. ? stop: receive stop selection 1: after starting a receive with a compare 0, the receiver operates in a continuous mode until a compare 1 is detected. 0: after completion of a data transfer when starting with a compare 0, the receiver stops the data transfer and waits for a new compare 0. 31 30 29 28 27 26 25 24 period 23 22 21 20 19 18 17 16 sttdly 15 14 13 12 11 10 9 8 ---stop start 76543210 ckg cki cko cks
279 32059l?avr32?01/2012 at32uc3b ? start: receive start selection ? ckg: receive clock gating selection ? cki: receive clock inversion cki affects only the receive clock and not the output clock signal. 1: the data inputs (data and frame sync signals) are sampled on receive clock rising edge. the frame sync signal output is shifted out on receive clock falling edge. 0: the data inputs (data and frame sync signals) are sampled on receive clock falling edge. the frame sync signal output is shifted out on receive clock rising edge. ? cko: receive clock output mode selection ? cks: receive clock selection start receive start 0 continuous, as soon as the receiver is enabled, and immediately after the end of transfer of the previous data. 1 transmit start 2 detection of a low level on rx_frame_sync signal 3 detection of a high level on rx_frame_sync signal 4 detection of a falling edge on rx_frame_sync signal 5 detection of a rising edge on rx_frame_sync signal 6 detection of any level change on rx_frame_sync signal 7 detection of any edge on rx_frame_sync signal 8 compare 0 others reserved ckg receive clock gating 0 none, continuous clock 1 receive clock enabled only if rx_frame_sync is low 2 receive clock enabled only if rx_frame_sync is high 3 reserved cko receive clock output mode rx_clock pin 0 none input-only 1 continuous receive clock output 2 receive clock only during data transfers output others reserved cks selected receive clock 0 divided clock 1 tx_clock clock signal 2 rx_clock pin 3 reserved
280 32059l?avr32?01/2012 at32uc3b 20.9.4 receive frame mode register name: rfmr access type: read/write offset: 0x14 reset value: 0x00000000 ? fslenhi: receive frame sync length high part the four msb of the fslen field. ? fsedge: receive frame sync edge detection determines which edge on frame sync wi ll generate the sr.rxsyn interrupt. ? fsos: receive frame sync output selection ? fslen: receive frame sync length this field defines the length of the receive frame sync signal an d the number of bits sampled and stored in the rshr register. when this mode is selected by the rcmr.start field, it also determines the length of the sampled data to be compared to the compare 0 or compare 1 register. note: the four most significant bits for this field are located in the fslenhi field. the pulse length is equal to ({fslenhi,fslen} + 1) receive clock periods. thus, if {fslenhi,fslen} is zero, the receive frame sync signal is generated during one receive clock period. 31 30 29 28 27 26 25 24 fslenhi - - - fsedge 23 22 21 20 19 18 17 16 - fsos fslen 15 14 13 12 11 10 9 8 ---- datnb 76543210 msbf - loop datlen fsedge frame sync edge detection 0 positive edge detection 1 negative edge detection fsos selected receive frame sy nc signal rx_f rame_sync pin 0 none input-only 1 negative pulse output 2 positive pulse output 3 driven low during data transfer output 4 driven high during data transfer output 5 toggling at each start of data transfer output others reserved undefined
281 32059l?avr32?01/2012 at32uc3b ? datnb: data number per frame this field defines the number of data words to be received after each transfer start, which is equal to (datnb + 1). ? msbf: most significant bit first 1: the most significant bit of the data register is sampled first in the bit stream. 0: the lowest significant bit of the data register is sampled first in the bit stream. ? loop: loop mode 1: rx_data is driven by tx_data, rx_frame_sync is dr iven by tx_frame_sync and tx_clock drives rx_clock. 0: normal operating mode. ? datlen: data length the bit stream contains (datlen + 1) data bits. this field also defines the transfer size performed by the peripheral dma controller assigned to the receiver. datlen transfer size 0 forbidden value 1-7 data transfer are in bytes 8-15 data transfer are in halfwords others data transfer are in words
282 32059l?avr32?01/2012 at32uc3b 20.9.5 transmit clock mode register name: tcmr access type: read/write offset: 0x18 reset value: 0x00000000 ? period: transmit period divider selection this field selects the divider to apply to the selected tran smit clock in order to generate a periodic frame sync signal. if equal to zero, no signal is generated. if not equal to zero, a signal is generated each 2 x (period+1) transmit clock periods. ? sttdly: transmit start delay if sttdly is not zero, a delay of sttdly clock cycles is inse rted between the start event and the actual start of transmission. when the transmitter is programmed to start synchronously with the receiver, the delay is also applied. note: sttdly must be written carefully, in relation to transmit sync data transmission. ? start: transmit start selection 31 30 29 28 27 26 25 24 period 23 22 21 20 19 18 17 16 sttdly 15 14 13 12 11 10 9 8 - - - - start 76543210 ckg cki cko cks start transmit start 0 continuous, as soon as a word is written to the thr register (if transmit is enabled), and immediately after the end of transfer of the previous data. 1 receive start 2 detection of a low level on tx_frame_sync signal 3 detection of a high level on tx_frame_sync signal 4 detection of a falling edge on tx_frame_sync signal 5 detection of a rising edge on tx_frame_sync signal 6 detection of any level change on tx_frame_sync signal 7 detection of any edge on tx_frame_sync signal others reserved
283 32059l?avr32?01/2012 at32uc3b ? ckg: transmit clock gating selection ? cki: transmit clock inversion cki affects only the transmit clock and not the output clock signal. 1: the data outputs (data and frame sync signals) are shifted out on transmit clock rising edge. the frame sync signal input is sampled on transmit clock falling edge. 0: the data outputs (data and frame sync si gnals) are shifted out on transmit clock falling edge. the frame sync signal input i s sampled on transmit clock rising edge. ? cko: transmit clock output mode selection ? cks: transmit clock selection ckg transmit clock gating 0 none, continuous clock 1 transmit clock enabled only if tx_frame_sync is low 2 transmit clock enabled only if tx_frame_sync is high 3 reserved cko transmit clock output mode tx_clock pin 0 none input-only 1 continuous transmit clock output 2 transmit clock only during data transfers output others reserved cks selected transmit clock 0 divided clock 1 rx_clock clock signal 2 tx_clock pin 3 reserved
284 32059l?avr32?01/2012 at32uc3b 20.9.6 transmit frame mode register name: tfmr access type: read/write offset: 0x1c reset value: 0x00000000 ? fslenhi: transmit frame sync length high part the four msb of the fslen field. ? fsedge: transmit frame sync edge detection determines which edge on frame sync wi ll generate the sr.txsyn interrupt. ? fsden: transmit frame sync data enable 1: tshr value is shifted out during the transmission of the transmit frame sync signal. 0: the tx_data line is driven with the default value during the transmit frame sync signal. ? fsos: transmit frame sync output selection ? fslen: transmit frame sync length this field defines the length of the transmit frame sync signal and the number of bits shifted out from the tshr register if tfmr.fsden is equal to one. note: the four most significant bits for this field are located in the fslenhi field. 31 30 29 28 27 26 25 24 fslenhi - - - fsedge 23 22 21 20 19 18 17 16 fsden fsos fslen 15 14 13 12 11 10 9 8 ---- datnb 76543210 msbf - datdef datlen fsedge frame sync edge detection 0 positive edge detection 1 negative edge detection fsos selected transmit frame sync signal tx_frame_sync pin 0 none input-only 1 negative pulse output 2 positive pulse output 3 driven low during data transfer output 4 driven high during data transfer output 5 toggling at each start of data transfer output others reserved undefined
285 32059l?avr32?01/2012 at32uc3b the pulse length is equal to ({fslenhi,fslen} + 1) transmit clock periods, i.e., the pulse length can range from 1 to 256 transmit clock periods. if {fslenhi,fslen} is zero, the transm it frame sync signal is generated during one transmit clock period. ? datnb: data number per frame this field defines the number of data words to be transferre d after each transfer start, which is equal to (datnb + 1). ? msbf: most significant bit first 1: the most significant bit of the data register is shifted out first in the bit stream. 0: the lowest significant bit of the data register is shifted out first in the bit stream. ? datdef: data default value this bit defines the level driven on the tx_data pin while out of transmission. note that if the pin is defined as multi-drive by the i/o controller, the pin is enabled only if the tx_data output is one. 1: the level driven on the tx_data pin while out of transmission is one. 0: the level driven on the tx_data pin while out of transmission is zero. ? datlen: data length the bit stream contains (datlen + 1) data bits. this field also defines the transfer size performed by the peripheral dma controller assigned to the transmitter. datlen transfer size 0 forbidden value (1-bit data length is not supported) 1-7 data transfer are in bytes 8-15 data transfer are in halfwords others data transfer are in words
286 32059l?avr32?01/2012 at32uc3b 20.9.7 receive holding register name: rhr access type: read-only offset: 0x20 reset value: 0x00000000 ? rdat: receive data right aligned regardless of the number of data bits defined by the rfmr.datlen field. 31 30 29 28 27 26 25 24 rdat[31:24] 23 22 21 20 19 18 17 16 rdat[23:16] 15 14 13 12 11 10 9 8 rdat[15:8] 76543210 rdat[7:0]
287 32059l?avr32?01/2012 at32uc3b 20.9.8 transmit holding register name: thr access type: write-only offset: 0x24 reset value: 0x00000000 ? tdat: transmit data right aligned regardless of the number of data bits defined by the tfmr.datlen field. 31 30 29 28 27 26 25 24 tdat[31:24] 23 22 21 20 19 18 17 16 tdat[23:16] 15 14 13 12 11 10 9 8 tdat[15:8] 76543210 tdat[7:0]
288 32059l?avr32?01/2012 at32uc3b 20.9.9 receive synchronization holding register name: rshr access type: read-only offset: 0x30 reset value: 0x00000000 ? rsdat: receive synchronization data 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 rsdat[15:8] 76543210 rsdat[7:0]
289 32059l?avr32?01/2012 at32uc3b 20.9.10 transmit synchronization holding register name: tshr access type: read/write offset: 0x34 reset value: 0x00000000 ? tsdat: transmit synchronization data 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 tsdat[15:8] 76543210 tsdat[7:0]
290 32059l?avr32?01/2012 at32uc3b 20.9.11 receive compare 0 register name: rc0r access type: read/write offset: 0x38 reset value: 0x00000000 ? cp0: receive compare data 0 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 cp0[15:8] 76543210 cp0[7:0]
291 32059l?avr32?01/2012 at32uc3b 20.9.12 receive compare 1 register name: rc1r access type: read/write offset: 0x3c reset value: 0x00000000 ? cp1: receive compare data 1 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 cp1[[15:8] 76543210 cp1[7:0]
292 32059l?avr32?01/2012 at32uc3b 20.9.13 status register name: sr access type: read-only offset: 0x40 reset value: 0x000000cc ? rxen: receive enable this bit is set when the cr.rxen bit is written to one. this bit is cleared when no data are being proces sed and the cr.rxdis bit has been written to one. ? txen: transmit enable this bit is set when the cr.txen bit is written to one. this bit is cleared when no data are being proces sed and the cr.txdis bit has been written to one. ? rxsyn: receive sync this bit is set when a receive sync has occurred. this bit is cleared when the sr register is read. ? txsyn: transmit sync this bit is set when a transmit sync has occurred. this bit is cleared when the sr register is read. ? cp1: compare 1 this bit is set when compare 1 has occurred. this bit is cleared when the sr register is read. ? cp0: compare 0 this bit is set when compare 0 has occurred. this bit is cleared when the sr register is read. ? ovrun: receive overrun this bit is set when data has been loaded in the rhr register while previous data has not yet been read. this bit is cleared when the sr register is read. ? rxrdy: receive ready this bit is set when data has been received and loaded in the rhr register. this bit is cleared when the rhr register is empty. ? txempty: transmit empty this bit is set when the last data written in the thr register has been loaded in the tsr register and last data loaded in the tsr register has been transmitted. this bit is cleared when data remains in the thr regist er or is currently transmitted from the tsr register. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - - - - - - rxen txen 15 14 13 12 11 10 9 8 - - - - rxsyn txsyn cp1 cp0 76543210 - - ovrun rxrdy - - txempty txrdy
293 32059l?avr32?01/2012 at32uc3b ? txrdy: transmit ready this bit is set when the thr register is empty. this bit is cleared when data has been loaded in the thr re gister and is waiting to be loaded in the tsr register.
294 32059l?avr32?01/2012 at32uc3b 20.9.14 interrupt enable register name: ier access type: write-only offset: 0x44 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - - - rxsyn txsyn cp1 cp0 76543210 ? ? ovrun rxrdy ? ? txempty txrdy
295 32059l?avr32?01/2012 at32uc3b 20.9.15 interrupt disable register name: idr access type: write-only offset: 0x48 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - - - rxsyn txsyn cp1 cp0 76543210 ? ? ovrun rxrdy ? ? txempty txrdy
296 32059l?avr32?01/2012 at32uc3b 20.9.16 interrupt mask register name: imr access type: read-only offset: 0x4c reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. a bit in this register is cleared when the corresponding bit in idr is written to one. a bit in this register is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - - - rxsyn txsyn cp1 cp0 76543210 ? ? ovrun rxrdy ? ? txempty txrdy
297 32059l?avr32?01/2012 at32uc3b 21. universal synchronous asynchro nous receiver transmitter (usart) rev: 4.0.0.6 21.1 features ? configurable baud rate generator ? 5- to 9-bit full-duplex, synchronous and asynchronous, serial communication ? 1, 1.5, or 2 stop bits in asynchronous mode, and 1 or 2 in synchronous mode ? parity generation and error detection ? framing- and overrun error detection ? msb- or lsb-first ? optional break generation and detection ? receiver frequency over-sampling by 8 or 16 times ? optional rts-cts hardware handshaking ? optional dtr-dsr-dcd-ri modem signal management ? receiver time-out and transmitter timeguard ? optional multidrop mode with address generation and detection ? rs485 with line driver control ? iso7816, t=0 and t=1 protocols for interfacing with smart cards ? , nack handling, and customizable error counter ? irda modulation and demodulation ? communication at up to 115.2kbit/s ? spi mode ? master or slave ? configurable serial clock phase and polarity ? clk spi serial clock frequency up to a quarter of the clk_usart internal clock frequency ? test modes ? automatic echo, remote- and local loopback ? supports two peripheral dma controller channels ? buffer transfers without processor intervention 21.2 overview the universal synchronous asynchronous receiver transceiver (usart) provides a full duplex, universal, synchronous/asynchronous serial link. data frame format is widely configu- rable, including basic length, parity, and stop bit settings, maximizing standards support. the receiver implements parity-, framing-, and overrun error detection, and can handle un-fixed frame lengths with the time-out feature. the usart supports se veral operating modes, provid- ing an interface to rs485 and spi buses, with iso7816 t=0 and t=1 smart card slots, infrared transceivers, and modem port connections. communication with slow and remote devices is eased by the timeguard. duplex multidrop comm unication is supported by address and data dif- ferentiation through the parity bit. the hardware handshaking feature enables an out-of-band flow control, automatically managing rts and cts pins. the peripheral dma controller con- nection enables memory tr ansactions, and the usart supports chained buffer management without processor intervention. automatic echo, remote-, and local loopback -test modes are also supported.
298 32059l?avr32?01/2012 at32uc3b 21.3 block diagram figure 21-1. usart block diagram peripheral dma controller channel channel intc power manager div receiver transmitter modem signals control user interface i/o controller rxd rts txd cts dtr dsr dcd ri clk baudrate generator usart interrupt clk_usart clk_usart/div usart peripheral bus table 21-1. spi operating mode pin usart spi slave spi master rxd rxd mosi miso txd txd miso mosi rts rts ? cs cts cts cs ?
299 32059l?avr32?01/2012 at32uc3b 21.4 i/o lines description 21.5 product dependencies 21.5.1 i/o lines the usart pins may be multiplexed with the i/o controller lines. the user must first configure the i/o controller to assign these pins to t heir peripheral functions. unused i/o lines may be used for other purposes. to prevent the txd line from falling when the usart is disabled, the use of an internal pull up is required. if the hardware handshaking feature or modem mode is used, the internal pull up on txd must also be enabled. all the pins of the modems may or may not be implemented on the usart. on usarts not equipped with the corresponding pins, the associat ed control bits and stat uses have no effect on the behavior of the usart. 21.5.2 clocks the clock for the usart bus interface (clk_usa rt) is generated by the power manager. this clock is enabled at reset, and can be disabled in the power manager. it is recommended to dis- able the usart before disabling the clock, to avoid freezing the usart in an undefined state. 21.5.3 interrupts the usart interrupt request line is connected to the interrupt controller. using the usart interrupt requires the interrupt controller to be programmed first. table 21-2. i/o lines description name description type active level clk serial clock i/o txd transmit serial data or master out slave in (mosi) in spi master mode or master in slave out (miso) in spi slave mode output rxd receive serial data or master in slave out (miso) in spi master mode or master out slave in (mosi) in spi slave mode input ri ring indicator input low dsr data set ready input low dcd data carrier detect input low dtr data terminal ready output low cts clear to send or slave select (nss) in spi slave mode input low rts request to send or slave select (nss) in spi master mode output low
300 32059l?avr32?01/2012 at32uc3b 21.6 functional description 21.6.1 selecting mode the usart can operate in several modes. the operating mode is selected by writing to the mode field in the ?mode register? (mr.mode). in addition, sy nchronous or asynchronous mode is selected by writing to the synchr onous mode select bit in mr (mr.sync). 21.6.2 baud rate generator the baud rate generator provides the bit period clock named the baud rate clock to both receiver and transmitter. it is based on a 16-bit di vider, which is specifi ed in the clock divider field in the baud rate generator register (brgr.cd). a non-zero value enables the generator, and if cd is one, the divider is bypassed and i nactive. the clock selection field in the mode register (mr.usclks) selects clock source between: ? clk_usart (internal clock, refer to power manager chapter for details) ? clk_usart/div (a divided clk_usart, re fer to module conf iguration section) ? clk (external clock, available on the clk pin) if the external clk clock is selected, the duration of the low and high levels of the signal pro- vided on the clk pin must be at least 4.5 time s longer than those provided by clk_usart. figure 21-2. baud rate generator 21.6.2.1 baud rate in asynchronous mode if the usart is configured to operate in an as ynchronous mode, the selected clock is divided by the cd value before it is provided to the rece iver as a sampling clo ck. depending on the over- sampling mode bit (mr.over) value, the clock is then divided by either 8 (over=1), or 16 (over=0). the baud rate is calculated with the following formula: this gives a maximum baud rate of clk_usar t divided by 8, assuming that clk_usart is the fastest clock possible, and that over is one. 16-bit counter cd usclks cd clk_usart clk_usart/div reserved clk sync sync usclks= 3 fidi over sampling divider baudrate clock sampling clock 1 0 0 clk 0 1 2 3 >1 1 1 0 0 baudrate selectedclock 82 over ? () cd () ----------------------------------------------- - =
301 32059l?avr32?01/2012 at32uc3b 21.6.2.2 baud rate calculation example table 21-3 shows calculations based on the cd field to obtain 38400 baud from different source clock frequencies. this table also shows the actual resulting baud rate and error. the baud rate is calculated with the following formula (over=0): the baud rate error is calculated with the following formula. it is not recommended to work with an error higher than 5%. 21.6.2.3 fractional baud rate in asynchronous mode the baud rate generator has a limitation: the sour ce frequency is always a multiple of the baud rate. an approach to this problem is to integrate a high resolution fractional n clock generator, outputting fractional multiples of the reference sour ce clock. this fractional part is selected with the fractional part field (brgr.fp), and is activa ted by giving it a non-zero value. the resolu- tion is one eighth of cd. the resulting baud rate is calculated using the following formula: table 21-3. baud rate example (over=0) source clock (hz) expected baud rate (bit/s) calculation result cd actual baud rate (bit/s) error 3 686 400 38 400 6.00 6 38 400.00 0.00% 4 915 200 38 400 8.00 8 38 400.00 0.00% 5 000 000 38 400 8.14 8 39 062.50 1.70% 7 372 800 38 400 12.00 12 38 400.00 0.00% 8 000 000 38 400 13.02 13 38 461.54 0.16% 12 000 000 38 400 19.53 20 37 500.00 2.40% 12 288 000 38 400 20.00 20 38 400.00 0.00% 14 318 180 38 400 23.30 23 38 908.10 1.31% 14 745 600 38 400 24.00 24 38 400.00 0.00% 18 432 000 38 400 30.00 30 38 400.00 0.00% 24 000 000 38 400 39.06 39 38 461.54 0.16% 24 576 000 38 400 40.00 40 38 400.00 0.00% 25 000 000 38 400 40.69 40 38 109.76 0.76% 32 000 000 38 400 52.08 52 38 461.54 0.16% 32 768 000 38 400 53.33 53 38 641.51 0.63% 33 000 000 38 400 53.71 54 38 194.44 0.54% 40 000 000 38 400 65.10 65 38 461.54 0.16% 50 000 000 38 400 81.38 81 38 580.25 0.47% 60 000 000 38 400 97.66 98 38 265.31 0.35% baudrate clkusart () cd 16 () ? = error 1 expectedbaudrate actualbaudrate -------------------------------------------------- - ?? ?? ? = baudrate selectedclock 82 over ? () cd fp 8 ------- + ?? ?? ?? ?? -------------------------------------------------------------------- =
302 32059l?avr32?01/2012 at32uc3b the modified architecture is presented below: figure 21-3. fractional baud rate generator 21.6.2.4 baud rate in synchronous and spi mode if the usart is configured to operate in synchr onous mode, the selected clock is divided by the brgr.cd field. this does not apply when clk is selected. when clk is selected the external frequency must be at least 4.5 times lower than the system clock, and when either clk or clk_usart/div are selected, cd must be even to ensure a 50/50 duty cycle. if clk_usar t is selected, the generator ensures this regardless of value. 21.6.2.5 baud rate in iso 7816 mode the iso7816 specificati on defines the bit rate with the following formula: where: ? b is the bit rate ? di is the bit-rate adjustment factor ? fi is the clock frequency division factor ? f is the iso7816 clock frequency (hz) usclks cd modulus control fp fp cd glitch-free logic 16-bit counter over sync sampling divider clk_usart clk_usart/div reserved clk clk baudrate clock sampling clock sync usclks = 3 >1 1 2 3 0 0 1 0 1 1 0 0 baudrate selectedclock cd ------------------------------------- - = b di fi ----- - f =
303 32059l?avr32?01/2012 at32uc3b di is a binary value encoded on a 4-bit field, named di, as represented in table 21-4 . fi is a binary value encoded on a 4-bi t field, named fi, as represented in table 21-5 . table 21-6 shows the resulting fi/di ratio, which is the ratio between the iso7816 clock and the baud rate clock. if the usart is configured to run in iso7816 mode, the clock selected by the mr.usclks field is first divided by the cd value before it can be output on the clk pin, to feed the smart card clock inputs, by writing a one to the clock output select bit (mr.clk0). it is then divided by the fi over di ratio value field in the fi di rati o register (fidi.fi_di_rat io), which can be up to 2047 in iso7816 mode. this will be rounded off to an integral so the user has to select a fi_di_ratio value that comes as close as possible to th e expected fi/di ratio. the fi_di_ratio reset value is 0x174 (372 in decima l) and is the most common divider between the iso7816 clock and bit rate (fi=372, di=1). figure 21-4 shows the relationship between the ele- mentary time unit (etu), corresponding to a bit period, and the iso 7816 clock. figure 21-4. elementary time unit (etu) table 21-4. binary and decimal values for di di field 0001 0010 0011 0100 0101 0110 1000 1001 di (decimal)1 2 4 8 163212 20 table 21-5. binary and decimal values for fi fi field 0000 0001 0010 0011 0100 0101 0110 1001 1010 1011 1100 1101 fi (decimal 372 372 558 744 1116 1488 1860 512 768 1024 1536 2048 table 21-6. possible values for the fi/di ratio fi 372 558 744 1116 1488 1860 512 768 1024 1536 2048 di=2 186 279 372 558 744 930 256 384 512 768 1024 di=4 93 139.5 186 279 372 465 128 192 256 384 512 di=8 46.5 69.75 93 139.5 186 232.5 64 96 128 192 256 di=16 23.25 34.87 46.5 69.75 93 116.2 32 48 64 96 128 di=32 11.62 17.43 23.25 34.87 46.5 58.13 16 24 32 48 64 di=12 31 46.5 62 93 124 155 42.66 64 85.33 128 170.6 di=20 18.6 27.9 37.2 55.8 74.4 93 25.6 38.4 51.2 76.8 102.4 1 etu fi_di_ratio iso7816 clock cycles iso7816 clock on clk iso7816 i/o line on txd
304 32059l?avr32?01/2012 at32uc3b 21.6.3 receiver and transmitter control after a reset, the transceiver is disabled. the re ceiver/transmitter is enabled by writing a one to either the receiver enable, or transmitter enab le bit in the control register (cr.rxen, or cr.txen). they may be enabled together a nd can be configured both before and after they have been enabled. the user can reset the usart receiver/transmitter at any time by writing a one to either the reset receiver (cr.rstrx), or reset transmitter (cr.rsttx) bit. this soft- ware reset clears status bits and resets internal state machines, immediately halting any communication. the user interface configur ation registers will re tain their values. the user can disable the receiver/transmitter by writing a one to either the receiver disable, or transmitter disable bit (cr.rxdis, or cr.txdis). if the receiver is disabled during a character reception, the usart will wait for the current character to be received before disabling. if the transmitter is disabled during transmission, the usart will wa it until both the current character and the character stored in the transmitter holding register (thr) are transmitted before dis- abling. if a timeguard has been implemented it will remain func tional during the transaction. 21.6.4 synchronous and asynchronous modes 21.6.4.1 transmitter operations the transmitter performs equally in both syn chronous and asynchronous operating modes (mr.sync). one start bit, up to 9 data bits, an opti onal parity bit, and up to two stop bits are successively shifted out on the txd pin at each falling edge of the serial clock. the number of data bits is selected by th e character length field (mr.chrl) and the mr.mode9 bit. nine bits are selected by writing a one to mode9, overriding any value in chrl. the parity bit configura- tion is selected in the mr.par field. the most significant bit first bit (mr.msbf) selects which data bit to send first. the number of stop bits is selected by the mr.nbstop field. the 1.5 stop bit configuration is only supported in asynchronous mode. figure 21-5. character transmit the characters are sent by writing to the c haracter to be transmitted field (thr.txchr). the transmitter reports status with the transmitter ready (txrdy) and transmitter empty (txempty) bits in the channel status regist er (csr). txrdy is set when thr is empty. txempty is set when both thr and the transmit shift register are empty (transmission com- plete). both txrdy and txempty are cleared wh en the transmitter is disabled. writing a character to thr while txrdy is zero has no effect and the written character will be lost. d0 d1 d2 d3 d4 d5 d6 d7 txd start bit parity bit stop bit example: 8-bit, parity enabled one stop baud rate clock
305 32059l?avr32?01/2012 at32uc3b figure 21-6. transmitter status 21.6.4.2 manchester encoder when the manchester endec is used, characters transmitted through the usart are encoded in manchester ii biphase format. to enable this mode, write a one to mr.man. depending on polarity configuration, as se lected by the transmiss ion manchester polarity bit in the man- chester configuration register (man.tx_mopl), a logic level (zero or one), is transmitted as the transition from high -to-low or low-to-high duri ng the middle of each bit period. this consumes twice the bandwidth than the simpler nrz coding schemes, but the receiver has more error con- trol since the expected input has a transition at every mid-bit period. an example of a manchester encoded sequence is the byte 0xb1 or 10110001 being encoded to 10 01 10 10 01 01 01 10, assuming default encoder polarity. figure 21-7 illustrates this coding scheme. figure 21-7. nrz to manchester encoding a manchester encoded character can be preceded by both a preamble sequence, and a start frame delimiter. the preamble sequence is a pre-defined pattern with a configurable length from 1 to 15 bit periods. if the preamb le length is zero, the preamble waveform is not generated. the length is selected by writing to the transmitt er preamble length field (man.tx_pl). the avail- able preamble sequence patterns are: all_one, all_zero, one_zero or zero_one, and are selected by writing to the transmitter preamble pattern field (man.tx_pp). figure 21-8 illustrates the supp orted pa tterns. d0 d1 d2 d3 d4 d5 d6 d7 txd start bit parity bit stop bit baud rate clock start bit write thr d0 d1 d2 d3 d4 d5 d6 d7 parity bit stop bit txrdy txempty nrz encoded data manchester encoded data 10110001 txd
306 32059l?avr32?01/2012 at32uc3b figure 21-8. preamble patterns, def ault polarity assumed the start frame delimiter selector bit (mr.onebit) configures the manchester start bit pattern following the preamble. if mr.onebi t is one, a manchester encoded zero is transmitted to indi- cate that a new character is about to be sent. if mr.onebit is zero, a synchronization pattern is sent for the duration of three bit periods to inaugurate the new character. the sync pattern wave- form by itself is an invalid manchester encoding , since the transition only occurs at the middle of the second bit period. the manchester synchronization mode bit (mr.mod sync) selects sync pattern, and this also defines if the character is data (modsync=0) with a zero to one transition, or a command (modsync=1) with a one to zero transition. when direct memory access is used, the sync pat- tern can be updated on-the-fly with a modified character located in memory. to enable this mode the variable synchronization of command/data sync start frame delimiter bit (mr.var_sync) has to be written to one. in this case, modsync is bypassed and thr.txsynh selects the sync type to be included. figure 21-9 illustrates supp orted patterns. manchester encoded data txd sfd data 8 bit width "all_one" preamble manchester encoded data txd sfd data 8 bit width "all_zero" preamble manchester encoded data txd sfd data 8 bit width "zero_one" preamble manchester encoded data txd sfd data 8 bit width "one_zero" preamble
307 32059l?avr32?01/2012 at32uc3b figure 21-9. start frame delimiter manchester drift compensation the drift compensation bit (man.drift) enables a hardware drift compensation and recovery system that allows for sub-opti mal clock drifts without further user intervention. drift compensa- tion is only available in 16x oversamp ling mode. if the rxd event is one 16 th clock cycle from the expected edge, it is considered as normal jitter and no corrective action will be taken. if the event is two to four 16 th ?s early, the current peri od will be shortened by a 16 th . if the event is two to three 16 th ?s after the expected edge, the curr ent period will be prolonged by a 16 th . figure 21-10. bit resynchronization 21.6.4.3 asynchronous receiver if the usart is configured in an asynchronous operating mode (mr.sync = 0), the receiver will oversample the rxd input line by either 8 or 16 times the baud rate clock, as selected by the oversampling mode bit (mr.over). if the line is ze ro for half a bit period (four or eight consecu- tive samples, respective ly), a start bit will be assumed, and the following 8th or 16th sample will determine the logical value on the line, in effect resulting in bit values being determined at the middle of the bit period. the number of data bits, endianess, parity mode, and stop bits are selected by the same bits and fields as for the transmitter (mr.chrl, mode9, msbf, par, and nbstop). the synchro- manchester encoded data txd sfd data one bit start frame delimiter preamble length is set to 0 manchester encoded data txd sfd data command sync start frame delimiter manchester encoded data txd sfd data data sync start frame delimiter rxd oversampling 16x clock sampling point expected edge tolerance synchro. jump sync jump synchro. error synchro. error
308 32059l?avr32?01/2012 at32uc3b nization mechanism will only consider one stop bit, regardless of the used protocol, and when the first stop bit has been sampled, the receiver will automatically begin looking for a new start bit, enabling resynchronization even if there is a protocol miss-match. figure 21-11 and figure 21-12 illustrate start bit detection and char acter reception in asynchronous mode. figure 21-11. asynchronous star t bit detection figure 21-12. asynchronous character reception 21.6.4.4 manchester decoder when mr.man is one, the manchester endec is enabled. the decoder can detect selectable preamble sequences and start frame delimiters. the receiver manchester polarity bit (man.rx_mpol) selects input stream polar ity. the receiver preamble length field (man.rx_pl) specifies the length characteristics of detectable prea mbles, and if written to zero the preamble pattern detection will be disabled. the receiver preamble pattern field (man.rx_pp) selects the pattern to be detected. see figure 21-8 for available preamble pat- terns. figure 21-13 illustrates two types of manchest er preamble pattern mismatches. the manchester endec uses the same start fr ame delimiter selector (mr.onebit) for both encoder and decoder. if on ebit is one, only a ma nchester encoded zero will be accepted as a valid start frame delimiter. if onebit is zero, a data or command sync pattern will be expected. the received sync bit in the receive holding regi ster (rhr.rxsynh) will be zero if it is a data sync, and a one if it is a command sync. sampling clock (x16) rxd start detection sampling baud rate clock rxd start rejection sampling 12345678 12345670 1234 12345678 9 10111213141516 d0 sampling d0 d1 d2 d3 d4 d5 d6 d7 rxd parity bit stop bit example: 8-bit, parity enabled baud rate clock start detection 16 samples 16 samples 16 samples 16 samples 16 samples 16 samples 16 samples 16 samples 16 samples 16 samples
309 32059l?avr32?01/2012 at32uc3b figure 21-13. preamble pattern mismatch the receiver samples the rx line in continuos bit period quarters, making the smallest time frame in which to assume a bit value three quarte rs. a start bit is assume d if rxd is zero during one of these quarters. see figure 21-14 . figure 21-14. asynchronous star t bit detection if a valid preamble pattern or start frame delimit er is detected, the receiver continues decoding with the same synchronization. if the stream does not match a valid preamble pattern or a start frame delimiter, the receiver re-synchronizes at the next valid edge. when a valid start sequence has been detected, the decoded data is passed to the usart and the user will be notified of any incoming manchester encoding violations by the manchester error bit (csr.mane). this bit is cleared by writing a one to the reset status bits in the control register (cr.rststa). a vio- lation occurs when there is no transition in the middle of a bit period. see figure 21-15 for an illustration of a violation causing th e manchester error bit to be set. figure 21-15. manchester error 21.6.4.5 radio interface: manchester endec application this section describes low data rate, full duplex, dua l frequency, rf systems integrated with a manchester endec, that support ask an d/or fsk modulati on schemes. see figure 21-16 . manchester encoded data txd sfd data preamble length is set to 8 preamble mismatch invalid pattern preamble mismatch manchester coding error manchester encoded data txd 1234 sampling clock (16 x) start detection manchester encoded data txd sfd preamble length is set to 4 elementary character bit time manchester coding error detected sampling points preamble subpacket and start frame delimiter were successfully decoded entering usart character area
310 32059l?avr32?01/2012 at32uc3b figure 21-16. manchester encoded char acters rf transmission to transmit downstream, encoded data is sent serially to the rf modulator and then through space to the rf receiver. to receive, another frequency carrier is used and the rf demodulator does a bit-checking search for valid patterns before it switches to a receiving mode and forwards data to the decoder. defining preambles to help distinguish between noise and valid data has to be done in conjunction with the rf module, and may sometimes be filtered away from the endec stream. using the ask modulation scheme, a one is transmitted as a rf signal at the down- stream frequency, while a zero is transmitted as no signal. see figure 21-17 the fsk modulation scheme uses two differ ent frequencies to transmit data. a one is sent as a signal on one frequency, and a zero on the other. see figure 21-18 . figure 21-17. ask modulator output lna vco rf filter demod control bi-dir line pa rf filter mod vco control manchester decoder manchester encoder usart receiver usart emitter ask/fsk upstream receiver ask/fsk downstream transmitter upstream emitter downstream receiver serial configuration interface fup frequency carrier fdown frequency carrier manchester encoded data default polarity unipolar output txd ask modulator output uptstream frequency f0 nrz stream 10 0 1
311 32059l?avr32?01/2012 at32uc3b figure 21-18. fsk modulator output 21.6.4.6 synchronous receiver in synchronous mode (sync=1), the receiver samples the rxd signal on each rising edge of the baud rate clock. if a low level is detected, it is considered as a start bit. configuration bits and fields are the same as in asynchronous mode. figure 21-19. synchronous mode character reception 21.6.4.7 receiver operations when a character reception is comp leted, it is transferred to the received character field in the receive holding register (rhr.rxchr), and the receiver ready bit in the channel status register (csr.rxrdy) is set. if rxrdy is alre ady set, rhr will be overwritten and the overrun error bit (csr.ovre) is set. reading rhr w ill clear csr.rxrdy, and writing a one to the reset status bit in the control register (cr.rststa) will clear csr.ovre. manchester encoded data default polarity unipolar output txd fsk modulator output uptstream frequencies [f0, f0+offset] nrz stream 10 0 1 d0 d1 d2 d3 d4 d5 d6 d7 rxd start sampling parity bit stop bit example: 8-bit, parity enabled 1 stop baud rate clock
312 32059l?avr32?01/2012 at32uc3b figure 21-20. receiver status 21.6.4.8 parity the usart supports five parity modes selected by mr.par. the par field also enables the multidrop mode, see ?multidrop mode? on page 313 . if even parity is selected, the parity bit will be a zero if there is an even number of ones in the data character, and if there is an odd number it will be a one. for odd pa rity the reverse applies. if space or mark parity is chosen, the parity bit will always be a zero or one, respectively. see table 21-7 . the receiver will report parity errors in csr.par e, unless parity is disabled. writing a one to cr.rststa will clear csr.pare. see figure 21-21 . figure 21-21. parity error d0 d1 d2 d3 d4 d5 d6 d7 rxd start bit parity bit stop bit baud rate clock write cr rxrdy ovre d0 d1 d2 d3 d4 d5 d6 d7 start bit parity bit stop bit rststa = 1 read rhr table 21-7. parity bit examples alphanum character hex bin parity mode odd even mark space none a 0x41 0100 0001 1 0 1 0 - v 0x56 0101 0110 1 0 1 0 - r 0x52 0101 0010 0 1 1 0 - d0 d1 d2 d3 d4 d5 d6 d7 rxd start bit bad parity bit stop bit baud rate clock write cr pare rxrdy rststa = 1
313 32059l?avr32?01/2012 at32uc3b 21.6.4.9 multidrop mode if par is either 0x6 or 0x7, the usart runs in multidrop mode. this mode differentiates data and address characters. data has the parity bit zero and addresses have a one. by writing a one to the send address bit (cr.senda) the user will cause the next character written to thr to be transmitted as an address. rece iving a character with a one as parity bit will set csr.pare. 21.6.4.10 transmitter timeguard the timeguard feature enables the usart to interf ace slow devices by inse rting an idle state on the txd line in between two characters. this idle state corresponds to a long stop bit, whose duration is selected by the timeguard value field in the transmitter timeguard register (ttgr.tg). the transmitte r will hold the txd line high for tg bit periods, in addition to the num- ber of stop bits. as illustrated in figure 21-22 , the behavior of txrdy and txempty is modified when tg has a non-zero value. if a pending character has been written to thr, the txrdy bit will not be set until this characters start bit has been sent. txempty will remain low until the timeguard transmission has completed. figure 21-22. timeguard operation d0 d1 d2 d3 d4 d5 d6 d7 txd start bit parity bit stop bit b aud rate clock start bit tg = 4 write thr d0 d1 d2 d3 d4 d5 d6 d7 parity bit stop bit txrdy t xempty tg = 4 table 21-8. maximum baud rate dependent timeguard durations baud rate (bit/sec) bit time (s) timeguard (ms) 1 200 833 212.50 9 600 104 26.56 14400 69.4 17.71 19200 52.1 13.28 28800 34.7 8.85 33400 29.9 7.63 56000 17.9 4.55 57600 17.4 4.43 115200 8.7 2.21
314 32059l?avr32?01/2012 at32uc3b 21.6.4.11 receiver time-out the time-out value field in the receiver time-o ut register (rtor.to) enables handling of vari- able-length frames by detection of selectable idle durations on the rxd line. the value written to to is loaded to a decr emental counter, and unless it is ze ro, a time-out will occur when the amount of inactive bit periods match the initial co unter value. if a time-out has not occurred, the counter will reload and restart ever y time a new character arrives. a time-out sets the timeout bit in csr. clearing timeout can be done in two ways: ? writing a one to the start time-out bit (cr.sttto). this also aborts count down until the next character has been received. ? writing a one to the reload and start time -out bit (cr.retto). th is also reloads the counter and restarts count down immediately. figure 21-23. receiver time-o ut block diagram table 21-9. maximum time-out period baud rate (bit/sec) bit time (s) time-out (ms) 600 1 667 109 225 1 200 833 54 613 2 400 417 27 306 4 800 208 13 653 9 600 104 6 827 14400 69 4 551 19200 52 3 413 28800 35 2 276 33400 30 1 962 56000 18 1 170 57600 17 1 138 200000 5 328 16-bit time-out counter 0 to timeout baud rate clock = character received retto load clock 16-bit value sttto dq 1 clear
315 32059l?avr32?01/2012 at32uc3b 21.6.4.12 framing error the receiver is capable of detecting framing erro rs. a framing error has occurred if a stop bit reads as zero. this can occur if the transmitte r and receiver are not synchronized. a framing error is reported by csr.frame as soon as the error is detected, at the middle of the stop bit. figure 21-24. framing error status 21.6.4.13 transmit break when csr.txrdy is set, the us er can request the transmitter to generate a break condition on the txd line by writing a one to the start break bit (cr.sttbrk). the break is treated as a nor- mal 0x00 character transmission, clearing csr. txrdy and csr.txempty, but with zeroes for preambles, start, parity, stop, and time guard bits. writing a one to the stop break bit (cr.stbrk) will stop the generati on of new break characters, a nd send ones for tg duration or at least 12 bit periods, ensuring that the rece iver detects end of break, before resuming normal operation. figure 21-25 illustrates sttbrk and stpbr k effect on the txd line. writing to cr.sttbrk and cr.stpbrk simult aneously can lead to unpredictable results. writes to thr before a pendin g break has started will be ignored. figure 21-25. break transmission 21.6.4.14 receive break a break condition is assumed when incoming data , parity, and stop bits are zero. this corre- sponds to a framing error, but frame will remain zero while the break received/end of break d0 d1 d2 d3 d4 d5 d6 d7 rxd start bit parity bit stop bit baud rate clock write cr frame rxrdy rststa = 1 d0 d1 d2 d3 d4 d5 d6 d7 txd start bit parity bit stop bit baud rate clock write cr txrdy txempty stpbrk = 1 sttbrk = 1 break transmission end of break
316 32059l?avr32?01/2012 at32uc3b bit (csr.rxbrk) is set. writing a one to cr.r ststa will clear csr.rxbrk. an end of break will also set csr.rxbrk, and is as sumed when tx is hi gh for at least 2/16 of a bit period in asynchronous mode, or when a high le vel is sampled in synchronous mode. 21.6.4.15 hardware handshaking the usart features an out-of-band hardwar e handshaking flow control mechanism, imple- mentable by connecting the rts and cts pins with the remote device, as shown in figure 21- 26 . figure 21-26. connection with a remote device for hardware handshaking writing 0x2 to the mr.mode fiel d configures the usart to oper ate in this mode. the receiver will drive its rts pin high when disabled or when the reception buffer full bit (csr.rxbuff) is set by the buffer full signal from the peripheral dma controller. if the re ceivers rts pin is high, the transmitters cts pin will also be high and only th e active character tr ansactions will be com- pleted. allocating a new buffer to the dma contro ller by clearing rxbuff, will drive the rts pin low, allowing the transmitter to resume trans mission. detected level changes on the cts pin can trigger interrupts, and are reported by the cts input change bit in the channel status reg- ister (csr.ctsic). figure 21-27 illustrates receiver functionality, and figure 21-28 illustrates transmitter functionality. figure 21-27. receiver behavior when operating with hardware handshaking figure 21-28. transmitter behavior when operating with hardware handshaking usart txd cts remote device rxd txd rxd rts rts cts rts r xbuff write cr rxen = 1 rxd rxdis = 1 cts txd
317 32059l?avr32?01/2012 at32uc3b 21.6.5 iso7816 mode the usart features an iso7816-compatible mode, enabling interfacing with smart cards and security access modules (sam) through an iso7816 compliant link. t=0 and t=1 protocols, as defined in the iso7816 standard, are supported by writing 0x4 and 0x6 respectively to mr.mode. 21.6.5.1 iso7816 mode overview iso7816 specifies half duplex communication on on e bidirectional line. the baud rate is a frac- tion of the clock provided by the master on the clk pin (see ?baud rate generator? on page 300 ). the usart connects to a smart card as shown in figure 21-29 . the txd pin is bidirec- tional and is routed to the receiver when the tr ansmitter is disabled. ha ving both receiver and transmitter enabled simultaneously may lead to unpredictable results. figure 21-29. usart (master) connected to a smart card in both t=0 and t=1 modes, the ch aracter format is fixed to eigh t data bits, and one or two stop bits, regardless of chrl, mode9, and chmode va lues. parity accordi ng to specification is even. if the inverse transmission format is used, where payload data bits are transmitted inverted on the i/o line, the user can use odd parity and perform an xor on data headed to thr and coming from rhr. 21.6.5.2 protocol t=0 in t=0 protocol, a character is made up of one star t bit, eight data bits, one parity bit, and a two bit period guard time. during the guard time, the line will be high if the receiver does not signal a parity error, as shown in figure 21-30 . the receiver signals a parity error, aka non-acknowledge (nack), by pulling the line low for a bit period within the guard time, resulting in the total charac- ter length being incremented by one, see figure 21-31 . the usart will not load data to rhr if it detects a parity error, and will set pare if it receives a nack. figure 21-30. t=0 protocol without parity error clk txd usart clk i/o smart card d0 d1 d2 d3 d4 d5 d6 d7 rxd parity bit baud rate clock start bit guard time 1 next start bit guard time 2
318 32059l?avr32?01/2012 at32uc3b figure 21-31. t=0 protocol with parity error 21.6.5.3 protocol t=1 in t=1 protocol, the character resembles an as ynchronous format with only one stop bit. the parity is generated when transmitting and chec ked when receiving. parity errors set pare. 21.6.5.4 receive error counter the usart receiver keeps count of up to 255 errors in the number of errors field in the num- ber of error register (ner.nb_errors). re ading ner automatically clears nb_errors. 21.6.5.5 receive nack inhibit the usart can be configured to ignore parity errors by writing a one to the inhibit non acknowledge bit (mr.inack). erro neous characters will be treated as if they were ok, not gen- erating a nack, loaded to rhr, and raising rxrdy. 21.6.5.6 transmit ch aracter repetition the usart can be configured to automatically re -send a character if it receives a nack. writ- ing a value other than zero to mr.max_iteration will enable and determine the number of consecutive re-transmissions. if the number of unsuccessful re-transmissions equal max_iteration, the iteration bit (csr.iter) is set. writing a one to the reset iteration bit (cr.rstit) will clear iter. 21.6.5.7 disable successive receive nack the receiver can limit the number of consecutiv e nack?s to the value in max_iteration. this is enabled by writing a one to the disable succ essive nack bit (mr.dsnack). if the number of nack?s is about to surpass m ax_iteration, the character will instead be accepted as valid and iter is set. 21.6.6 irda mode the usart features an irda mode, supporting asynchronous, half-duplex, point-to-point wire- less communication. it embeds the modulator and demodulator, allowing for a glueless connection to the infrared transceivers, as shown in figure 21-32 . writing 0x8 to mr.mode enables this mode, and activates the irda spec ification v1.1 compliant modem. data transfer speeds ranging from 2.4kbit/s to 115.2kbit/s ar e supported and the character format is fixed to one start bit, eight data bits, and one stop bit. d0 d1 d2 d3 d4 d5 d6 d7 i/o parity bit baud rate clock start bit guard time 1 start bit guard time 2 d0 d1 error repetition
319 32059l?avr32?01/2012 at32uc3b figure 21-32. connection to irda transceivers the receiver and the transmitter must be exclusiv ely enabled or disabled, according to the direc- tion of the transmission. to receive irda signals, the following needs to be done: ? disable tx and enable rx. ? configure the txd pin as an i/o, outputting zero to avoid led activation. disable the internal pull-up for improved power consumption. ? receive data. 21.6.6.1 irda modulation the rzi modulation scheme is used, where a ze ro is represented by a light pulse one 3/16 th of a bit period, and no pulse to represent a one. some examples of si gnal pulse duration are shown in table 21-10 . figure 21-33 shows an example of character transmission. irda transceivers rxd rx txd tx usart demodulator modulator receiver transmitter table 21-10. irda pulse duration baud rate pulse duration (3/16) 2.4 kbit/s 78.13 s 9.6 kbit/s 19.53 s 19.2 kbit/s 9.77 s 38.4 kbit/s 4.88 s 57.6 kbit/s 3.26 s 115.2 kbit/s 1.63 s
320 32059l?avr32?01/2012 at32uc3b figure 21-33. irda modulation 21.6.6.2 irda baud rate as the irda mode shares some logic with the iso7816 mode, the fidi.fi_di_ratio field needs to be configured correctly. see section ?21.6.2.5? on page 302. table 21-11 gives some exam- ples of brgr.cd values, baud rate error, and pul se duration. note that the maximal acceptable error rate of 1.8 7% must be met. bit period bit period 3 16 start bit data bits stop bit 0 0 0 0 0 1 1 1 1 1 transmitter output txd table 21-11. irda baud rate error peripheral clock baud rate cd baud rate error pulse time 3 686 400 115 200 2 0.00% 1.63 20 000 000 115 200 11 1.38% 1.63 32 768 000 115 200 18 1.25% 1.63 40 000 000 115 200 22 1.38% 1.63 3 686 400 57 600 4 0.00% 3.26 20 000 000 57 600 22 1.38% 3.26 32 768 000 57 600 36 1.25% 3.26 40 000 000 57 600 43 0.93% 3.26 3 686 400 38 400 6 0.00% 4.88 20 000 000 38 400 33 1.38% 4.88 32 768 000 38 400 53 0.63% 4.88 40 000 000 38 400 65 0.16% 4.88 3 686 400 19 200 12 0.00% 9.77 20 000 000 19 200 65 0.16% 9.77 32 768 000 19 200 107 0.31% 9.77 40 000 000 19 200 130 0.16% 9.77 3 686 400 9 600 24 0.00% 19.53 20 000 000 9 600 130 0.16% 19.53 32 768 000 9 600 213 0.16% 19.53 40 000 000 9 600 260 0.16% 19.53
321 32059l?avr32?01/2012 at32uc3b 21.6.6.3 irda demodulator the demodulator depends on an 8-bit down counter loaded with the value in irda_filter field in the irda filter register (ifr.i rda_filter). when a falling edge on rxd is detected, the coun- ter starts decrementing at clk_ usart speed. if a rising edge is detected on rxd, the counter stops and is reloaded with the ifr value. if no rising edge has been detected when the counter reaches zero, the receiver input is pulled low during one bit period. see figure 21-34 . writing a one to the infrared receive line filter bit (mr.filter), enables a noise filter that, instead of using just one sample, will choo se the majority value from three consecutive samples. figure 21-34. irda demodulator operations 21.6.7 rs485 mode the usart features an rs485 mode, supporting line driver control. this supplements normal synchronous and asynchronous mode by driving the rts pin high when the transmitter is oper- ating. the rts pin level is the inverse of the csr.txempty value. writing 0x1 to mr.mode enables this mode. a typical connection to a rs485 bus is shown in figure 21-35 . figure 21-35. typical connection to a rs485 bus if a timeguard has been configured the rts pin will remain high fo r the duration specified in tg, as shown in figure 21-36 . 3 686 400 2 400 96 0.00% 78.13 20 000 000 2 400 521 0.03% 78.13 32 768 000 2 400 853 0.04% 78.13 table 21-11. irda baud rate error (continued) peripheral clock baud rate cd baud rate error pulse time clk_usart rxd counter value receiver input 654 6 3 pulse rejected 264 53210 pulse accepted driven low during 16 baud rate clock cycles usart rts txd rxd differential bus
322 32059l?avr32?01/2012 at32uc3b figure 21-36. example of rts drive with timeguard enabled 21.6.8 modem mode the usart features a modem mo de, supporting asynchronous communication with the follow- ing signal pins: data terminal ready (dtr), data set ready (dsr), request to send (rts), clear to send (cts), data carrier detect (dcd), and ring indicator (ri). writing 0x3 to mr.mode enables this mode, and the usar t will behave as a data terminal equipment (dte), controlling dtr and rts, whilst detecting level changes on dsr, dcd, cts, and ri. table 21-12 shows usart signal pins with the corresponding standardized modem connections. the dtr pin is controlled by writing a one to the dtr enable and disable bits (dtren, dtrdis) in cr. it is low when enabled, and hi gh when disabled. the rts pin is controlled automatically. detected level changes can trigger interrupts, an d are reported by the respective input change bits (riic, dsric, dcdic, and ctsic) in csr. these status bit are au tomatically cleared when csr is read. when the cts pin goes high, the usart will wait for the transmitter to complete any ongoing character transmission before automatically disabling it. d0 d1 d2 d3 d4 d5 d6 d7 txd start bit parity bit stop bit baud rate clock tg = 4 write thr txrdy txempty rts table 21-12. circuit references usart pin v.24 ccitt direction txd 2 103 from terminal to modem rts 4 105 from terminal to modem dtr 20 108.2 from terminal to modem rxd 3 104 from modem to terminal cts 5 106 from terminal to modem dsr 6 107 from terminal to modem dcd 8 109 from terminal to modem ri 22 125 from terminal to modem
323 32059l?avr32?01/2012 at32uc3b 21.6.9 spi mode the usart features a serial peripheral interface (spi) link compliant mode, supporting syn- chronous, full-duplex communicati on, in both master and slave mode. writing 0xe (master) or 0xf (slave) to mr.mode will enable this mode. a spi in master mo de controls th e data flow to and from the other spi devices, who are in slave mode. it is possible to let devices take turns being masters (aka multi-master protocol), and one master may shift data simultaneously into several slaves, but only one slave may respond at a time. a slave is selected when its slave select (nss) signal has been raised by the ma ster. the usart can only generate one nss sig- nal, and it is possible to use standard i/o lines to address more than one slave. 21.6.9.1 modes of operation the spi system consists of two data lines and two control lines: ? master out slave in (mosi): this line supplies the data shifted from master to slave. in master mode this is connected to txd, and in slave mode to rxd. ? master in slave out (miso): this line supplies the data shifted from slave to master. in master mode this is connected to rxd, and in slave mode to txd. ? serial clock (clk): this is controlled by the master. one period per bit transmission. in both modes this is connected to clk. ? slave select (nss): this control line allows t he master to select or deselect a slave. in master mode this is connected to rts, and in slave mode to cts. changing spi mode after initial configuration has to be followed by a transceiver software reset in order to avoid unpredictable behavior. 21.6.9.2 baud rate the baud rate generator operates as described in ?baud rate in synchronous and spi mode? on page 302 , with the following requirements: in spi master mode: ? the clock selection field (mr.usclks) must not equal 0x3 (external clock, clk). ? the clock output select bit (mr.clko) must be one. ? the brgr.cd field must be at least 0x4. ? if usclks is one (internal divided clock, clk_ usart/div), the value in cd has to be even, ensuring a 50:50 duty cycle. cd can be odd if usclks is zero (internal clock, clk_usart). in spi slave mode: ? clk frequency must be at least four times lower than the system clock. 21.6.9.3 data transfer up to nine data bits are successively shifted out on the txd pin at each edge. there are no start, parity, or stop bits, and msb is always sent first. the spi clock polarity (mr.cpol), and spi clock phase (mr.cpha) bits configure cl k by selecting the edges upon which bits are shifted and sampled, resulting in four non-interoperable protocol modes, see table 21-13 . if mr.cpol is zero, the inactive state value of clk is logic level zero, and if mr.cpol is one, the inactive state value of clk is lo gic level one. if mr.cpha is zero, data is changed on the lead- ing edge of clk, and captured on the following edge of clk. if mr.cpha is one, data is captured on the leading edge of clk, and changed on the following edge of clk. a mas- ter/slave pair must use the same configuration, and the master must be reconfigured if it is to communicate with slaves using different configurations. see figures 21-37 and 21-38 .
324 32059l?avr32?01/2012 at32uc3b figure 21-37. spi transfer format (cpha= 1, 8 bits per transfer) figure 21-38. spi transfer format (cpha= 0, 8 bits per transfer) table 21-13. spi bus protocol modes spi bus protocol mode cpol cpha 001 100 211 310 clk cycle (for reference) clk (cpol= 1) mosi spi master ->txd spi slave ->rxd miso spi master ->rxd spi slave ->txd nss spi master ->rts spi slave ->cts msb msb 1 clk (cpol= 0) 3 5 6 78 lsb 1 2 3 4 6 65 5 43 21 lsb 24 clk cycle (for reference) clk (cpol= 0) clk (cpol= 1) mosi spi master -> txd spi slave -> rxd miso spi master -> rxd spi slave -> txd nss spi master -> rts spi slave -> cts msb 6 5 msb 6 5 4 43 32 21 1 lsb lsb 8 7 6 5 4 3 2 1
325 32059l?avr32?01/2012 at32uc3b 21.6.9.4 receiver and transmitter control see ?transmitter operations? on page 304 , and ?receiver operations? on page 311 . 21.6.9.5 character transmission and reception in spi master mode, the slave select line (nss) is asserted low one bit period before the start of transmission, and released high one bit period af ter every character transmission. a delay for at least three bit periods is always inserted in between characters. in order to address slave devices suppor ting the chip select acti ve after transfer (csaat) m ode, nss can be forced low by writing a one to the force spi chip sele ct bit (cr.rtsen/fcs). releasing nss when fcs is one, is only possible by writing a one to the release spi chip sele ct bit (cr.rtsdis/rcs). in spi slave mode, a low level on nss for at least on e bit period will allow the slave to initiate a transmission or reception. the underrun error bi t (csr.unre) is set if a character must be sent while thr is empty, and txd will be high during character transmission , as if 0xff was being sent. if a new character is written to thr it will be sent correctly during the next transmission slot. writing a one to cr.rststa will clear cs r.unre. to ensure correct behavior of the receiver in spi slave mode, the master device sending the frame must ensure a minimum delay of one bit period in between each character transmission. 21.6.9.6 receiver time-out receiver time-out?s are not possible in spi m ode as the baud rate clock is only active during data transfers. 21.6.10 21.6.11 test modes the internal loopback feature enables on-board diagnostics, and allows the usart to operate in three different test modes, with reconf igured pin functionality, as shown below. 21.6.11.1 normal mode during normal operation, a receivers rxd pin is connected to a transmitters txd pin. figure 21-39. normal mode configuration 21.6.11.2 automatic echo mode automatic echo mode allows bit-by-bit retransmis sion. when a bit is received on the rxd pin, it is also sent to the txd pin, as shown in figure 21-40 . transmitter configuration has no effect. receiver transmitter rxd txd
326 32059l?avr32?01/2012 at32uc3b figure 21-40. automatic echo mode configuration 21.6.11.3 local loopback mode local loopback mode c onnects the output of the transmitter dire ctly to the input of the receiver, as shown in figure 21-41 . the txd and rxd pins are not used. the rxd pin has no effect on the receiver and the txd pin is continuously driven high, as in idle state. figure 21-41. local loopback mode configuration 21.6.11.4 remote loopback mode remote loopback mode connects the rxd pin to the txd pin, as shown in figure 21-42 . the transmitter and the receiver are disabled and have no effect. this mode allows bit-by-bit retransmission. figure 21-42. remote loopback mode configuration receiver transmitter rxd txd receiver transmitter rxd txd 1 receiver transmitter rxd txd 1
327 32059l?avr32?01/2012 at32uc3b 21.7 user interface note: 1. values in the version register vary with the version of the ip block implementation. table 21-14. usart register memory map offset register name access reset 0x0000 control register cr write-only 0x00000000 0x0004 mode register mr read-write 0x00000000 0x0008 interrupt enable register ier write-only 0x00000000 0x000c interrupt disable register idr write-only 0x00000000 0x0010 interrupt mask register imr read-only 0x00000000 0x0014 channel status register csr read-only 0x00000000 0x0018 receiver holding register rhr read-only 0x00000000 0x001c transmitter holding register thr write-only 0x00000000 0x0020 baud rate generator register brgr read-write 0x00000000 0x0024 receiver time-out register rtor read-write 0x00000000 0x0028 transmitter timeguard register ttgr read-write 0x00000000 0x0040 fi di ratio register fidi read-write 0x00000174 0x0044 number of errors register ner read-only 0x00000000 0x004c irda filter register ifr read-write 0x00000000 0x0050 manchester configuration register man read-write 0x30011004 0x00fc version register version read-only 0x? (1)
328 32059l?avr32?01/2012 at32uc3b 21.7.1 control register name: cr access type: write-only offset: 0x0 reset value: 0x00000000 ? rtsdis/rcs: request to send di sable/release spi chip select writing a zero to this bit has no effect. writing a one to this bit when usart is not in spi master mode drives rts pin high. writing a one to this bit when usart is in spi master mode releases nss (rts pin). ? rtsen/fcs: request to send enable/force spi chip select writing a zero to this bit has no effect. writing a one to this bit when usart is not in spi master mode drives rts low. writing a one to this bit when usart is in spi master mode when; fcs=0: has no effect. fcs=1: forces nss (rts pin) low, even if usart is not tran smitting, in order to address spi slave devices supporting the csaat mode (chip select active after transfer). ? dtrdis: data termi nal ready disable writing a zero to this bit has no effect. writing a one to this bit drives dtr pin high. ? dtren: data terminal ready enable writing a zero to this bit has no effect. writing a one to this bit drives dtr pin low. ? retto: rearm time-out writing a zero to this bit has no effect. writing a one to this bit reloads the time-out counter and clears csr.timeout. ? rstnack: reset non acknowledge writing a zero to this bit has no effect. writing a one to this bit clears csr.nack. ? rstit: reset iterations writing a zero to this bit has no effect. writing a one to this bit clears csr.iter if iso7816 is enabled in mr.mode ? senda: send address writing a zero to this bit has no effect. writing a one to this bit will in multidrop mode send the next character written to thr as an address. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ????rtsdis/rcsrtsen/fcsdtrdisdtren 15 14 13 12 11 10 9 8 retto rstnack rstit senda sttto stpbrk sttbrk rststa 76543210 txdis txen rxdis rxen rsttx rstrx ? ?
329 32059l?avr32?01/2012 at32uc3b ? sttto: start time-out writing a zero to this bit has no effect. writing a one to this bit will abort any current time-out count down, and trigger a new count down when the next character has been received. csr.timeout is also cleared. ? stpbrk: stop break writing a zero to this bit has no effect. writing a one to this bit will stop the generation of break signal characters, and then send ones for ttgr.tg duration, or at l east 12 bit periods. no effect if no break is being transmitted. ? sttbrk: start break writing a zero to this bit has no effect. writing a one to this bit will start transmission of break charac ters when current characters present in thr and the transmit s hift register have been sent. no effect if a break signal is already being generated. csr.txrdy and csr.txempty will be cleared. ? rststa: reset status bits writing a zero to this bit has no effect. writing a one to this bit will clear the following bits in csr: pare, frame, ovre, manerr, unre, and rxbrk. ? txdis: transmitter disable writing a zero to this bit has no effect. writing a one to this bit disables the transmitter. ? txen: transmitter enable writing a zero to this bit has no effect. writing a one to this bit enables the transmitter if txdis is zero. ? rxdis: receiver disable writing a zero to this bit has no effect. writing a one to this bit disables the receiver. ? rxen: receiver enable writing a zero to this bit has no effect. writing a one to this bit enables the receiver if rxdis is zero. ? rsttx: reset transmitter writing a zero to this bit has no effect. writing a one to this bit will reset the transmitter. ? rstrx: reset receiver writing a zero to this bit has no effect. writing a one to this bit will reset the receiver.
330 32059l?avr32?01/2012 at32uc3b 21.7.2 mode register name: mr access type: read-write offset: 0x4 reset value: 0x00000000 ? onebit: start frame delimiter selector 0: the start frame delimiter is a command or data sync, as defined by modsync. 1: the start frame delimiter is a norm al start bit, as defined by modsync. ? modsync: manchester synchronization mode 0: the manchester start bit is either a 0-to-1 transition, or a data sync. 1: the manchester start bit is either a 1-to-0 transition, or a command sync. ? man: manchester encoder/decoder enable 0: manchester endec is disabled. 1: manchester endec is enabled. ? filter: infrared receive line filter 0: the usart does not filter the receive line. 1: the usart filters the receive line by doing three consecutive samples and uses the majority value. ? max_iteration this field determines the number of acceptabl e consecutive nack?s when in protocol t=0. ? var_sync: variable synchronization of command/data sync start frame delimiter 0: sync pattern according to modsync. 1: sync pattern according to thr.txsynh. ? dsnack: disable successive nack 0: nack?s are handled as normal, unless disabled by inack. 1: the receiver restricts the amount of consecutive nack?s by max_iteration value. if max_iteration=0 no nack will be issued and the first erroneous message is acce pted as a valid character, setting csr.iter. ? inack: inhibit non acknowledge 0: the nack is generated. 1: the nack is not generated. ? over: oversampling mode 0: oversampling at 16 times the baud rate. 1: oversampling at 8 times the baud rate. ? clko: clock output select 0: the usart does not drive the clk pin. 1: the usart drives the clk pin unless usclks selects the external clock. ? mode9: 9-bit character length 0: chrl defines character length. 31 30 29 28 27 26 25 24 onebit modsync man filter ? max_iteration 23 22 21 20 19 18 17 16 ? var_sync dsnack inack over clko mode9 msbf/cpol 15 14 13 12 11 10 9 8 chmode nbstop par sync/cpha 76543210 chrl usclks mode
331 32059l?avr32?01/2012 at32uc3b 1: 9-bit character length. ? msbf/cpol: bit order or spi clock polarity if usart does not operate in spi mode: msbf=0: least significant bit is sent/received first. msbf=1: most significant bit is sent/received first. if usart operates in spi mode, cpol is used with cpha to produce the required clock/data relationship between devices. cpol=0: the inactive state value of clk is logic level zero. cpol=1: the inactive state value of clk is logic level one. ? chmode: channel mode ? nbstop: number of stop bits ? par: parity type ? sync/cpha: synchronous mode select or spi clock phase if usart does not operate in spi mode (mode is 0xe and 0xf): sync = 0: usart operates in asynchronous mode. sync = 1: usart operates in synchronous mode. if usart operates in spi mode, cpha determines which edge of clk causes data to change and which edge causes data to be captured. cpha is used with cpol to produce the requir ed clock/data relationship between master and slave devices. cpha = 0: data is changed on the leading edge of clk and captured on the following edge of clk. cpha = 1: data is captured on the leading edge of clk and changed on the following edge of clk. table 21-15. chmode mode description 00normal mode 0 1 automatic echo. receiver input is connected to the txd pin. 1 0 local loopback. transmitter output is connected to the receiver input. 1 1 remote loopback. rxd pin is internally connected to the txd pin. table 21-16. nbstop asynchronous (sync=0) synchronous (sync=1) 0 0 1 stop bit 1 stop bit 0 1 1.5 stop bits reserved 1 0 2 stop bits 2 stop bits 1 1 reserved reserved table 21-17. par parity type 000even parity 001odd parity 0 1 0 parity forced to 0 (space) 0 1 1 parity forced to 1 (mark) 10xno parity 1 1 x multidrop mode
332 32059l?avr32?01/2012 at32uc3b ? chrl: character length. ? usclks: clock selection note: 1. the value of div is device dependent. please refer to the module configuration section at the end of this chapter. ?mode table 21-18. chrl character length 0 0 5 bits 0 1 6 bits 1 0 7 bits 1 1 8 bits table 21-19. usclks selected clock 0 0 clk_usart 0 1 clk_usart/div (1) 10reserved 11 clk table 21-20. mode mode of the usart 0000normal 0001rs485 0 0 1 0 hardware handshaking 0011modem 0 1 0 0 is07816 protocol: t = 0 0 1 1 0 is07816 protocol: t = 1 1000irda 1110spi master 1 1 1 1 spi slave others reserved
333 32059l?avr32?01/2012 at32uc3b 21.7.3 interrupt enable register name: ier access type: write-only offset: 0x8 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr. for backward compatibility the mane bit has been duplicated to the manea bit position . writing either o ne or the other has the same effect. 31 30 29 28 27 26 25 24 ???????manea 23 22 21 20 19 18 17 16 ? ? ? mane ctsic dcdic dsric riic 15 14 13 12 11 10 9 8 ? ? nack rxbuff ? iter/unre txempty timeout 76543210 pare frame ovre ? ? rxbrk txrdy rxrdy
334 32059l?avr32?01/2012 at32uc3b 21.7.4 interrupt disable register name: idr access type: write-only offset: 0xc reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr. for backward compatibility the mane bit has been duplicated to the manea bit position . writing either o ne or the other has the same effect. 31 30 29 28 27 26 25 24 ???????manea 23 22 21 20 19 18 17 16 ? ? ? mane ctsic dcdic dsric riic 15 14 13 12 11 10 9 8 ? ? nack rxbuff ? iter/unre txempty timeout 76543210 pare frame ovre ? ? rxbrk txrdy rxrdy
335 32059l?avr32?01/2012 at32uc3b 21.7.5 interrupt mask register name: imr access type: read-only offset: 0x10 reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. a bit in this register is cleared when the corresponding bit in idr is written to one. a bit in this register is set when the corresponding bit in ier is written to one. for backward compatibility the mane bit has been duplicated to the manea bit position. r eading either one or the other has the same effect. 31 30 29 28 27 26 25 24 ???????manea 23 22 21 20 19 18 17 16 ? ? ? mane ctsic dcdic dsric riic 15 14 13 12 11 10 9 8 ? ? nack rxbuff ? iter/unre txempty timeout 76543210 pare frame ovre ? ? rxbrk txrdy rxrdy
336 32059l?avr32?01/2012 at32uc3b 21.7.6 channel status register name: csr access type: read-only offset: 0x14 reset value: 0x00000000 ? manerr: manchester error 0: no manchester error has been detected since the last rststa. 1: at least one manchester error has been detected since the last rststa. ? cts: image of cts input 0: cts is low. 1: cts is high. ? dcd: image of dcd input 0: dcd is low. 1: dcd is high. ? dsr: image of dsr input 0: dsr is low. 1: dsr is high. ? ri: image of ri input 0: ri is low. 1: ri is high. ? ctsic: clear to send input change flag 0: no change has been detected on the cts pin since the last csr read. 1: at least one change has been detected on the cts pin since the last csr read. ? dcdic: data carrier detect input change flag 0: no change has been detected on the dcd pin since the last csr read. 1: at least one change has been detected on the dcd pin since the last csr read. ? dsric: data set read y input change flag 0: no change has been detected on the dsr pin since the last csr read. 1: at least one change has been detected on the dsr pin since the last csr read. 31 30 29 28 27 26 25 24 ???????manerr 23 22 21 20 19 18 17 16 cts dcd dsr ri ctsic dcdic dsric riic 15 14 13 12 11 10 9 8 ? ? nack rxbuff ? iter/unre txempty timeout 76543210 pare frame ovre ? ? rxbrk txrdy rxrdy
337 32059l?avr32?01/2012 at32uc3b ? riic: ring indicator input change flag 0: no change has been detected on the ri pin since the last csr read. 1: at least one change has been detected on the ri pin since the last csr read. ? nack: non acknowledge 0: no non acknowledge has been detected since the last rstnack. 1: at least one non acknowledge has been detected since the last rstnack. this bit is cleared by writing a one to cr.rstnack. ? rxbuff: reception buffer full 0: the buffer full signal from the peripheral dma controller channel is inactive. 1: the buffer full signal from the peripheral dma controller channel is active. ? iter/unre: max number of repetition s reached or spi underrun error if usart does not operate in spi slave mode: iter=0: maximum number of repetitions has not been reached since the last rststa. iter=1: maximum number of repetitions has been reached since the last rststa. if usart operates in spi slave mode: unre=0: no spi underrun error has occurred since the last rststa. unre=1: at least one spi underrun error has occurred since the last rststa. this bit is cleared by writing a one to cr.rststa. ? txempty: tran smitter empty 0: the transmitter is either disabled or there are char acters in thr, or in the transmit shift register. 1: there are no characters in neither thr, nor in the transmit shift register. this bit is cleared by writing a one to cr.sttbrk. ? timeout: receiver time-out 0: there has not been a time-out since the last start time-out command (cr.sttto), or rtor.to is zero. 1: there has been a time-out since the last start time-out command. this bit is cleared by writing a one to cr.sttto or cr.retto. ? pare: parity error 0: either no parity error has been detected, or the parity bit is a zero in multidrop mode, since the last rststa. 1: either at least one parity error has been detected, or the parity bit is a one in multidrop mode, since the last rststa. this bit is cleared by writing a one to cr.rststa. ? frame: framing error 0: no stop bit has been found as low since the last rststa. 1: at least one stop bit has been found as low since the last rststa. this bit is cleared by writing a one to cr.rststa. ? ovre: overrun error 0: no overrun error has occurred since the last rststa. 1: at least one overrun error has occurred since the last rststa. this bit is cleared by writing a one to cr.rststa. ? rxbrk: break received/end of break 0: no break received or end of break detected since the last rststa. 1: break received or end of break detected since the last rststa. this bit is cleared by writing a one to cr.rststa. ? txrdy: transmitter ready 0: the transmitter is either disabled, or a character in thr is waiting to be transferred to the transmit shift register, or an sttbrk command has been requested. as soon as the transmitter is enabled, txrdy is set. 1: there is no character in the thr. this bit is cleared by writing a one to cr.sttbrk. ? rxrdy: receiver ready 0: the receiver is either disabled, or no complete character has been received since the last read of rhr. if characters were being received when the receiver was disabled, rxrdy changes to 1 when the receiver is enabled. 1: at least one complete character has been received and rhr has not yet been read.
338 32059l?avr32?01/2012 at32uc3b this bit is cleared when the receiv e holding register (rhr) is read.
339 32059l?avr32?01/2012 at32uc3b 21.7.7 receiver holding register name: rhr access type: read-only offset: 0x18 reset value: 0x00000000 reading this register will clear the csr.rxrdy bit. ? rxsynh: received sync 0: last character received is a data sync. 1: last character received is a command sync. ? rxchr: received character last received character. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 rxsynh ??????rxchr[8] 76543210 rxchr[7:0]
340 32059l?avr32?01/2012 at32uc3b 21.7.8 transmitter holding register name: thr access type: write-only offset: 0x1c reset value: 0x00000000 ? txsynh: sync field to be transmitted 0: if mr.varsync is a one, the next character sent is encoded as data, and the start frame delimiter is a data sync. 1: if mr.varsync is a one, the next character sent is encoded as a command, and the start frame delimiter is a command sync. ? txchr: character to be transmitted if txrdy is zero this field contains the next character to be transmitted. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 txsynh ??????tx chr[8] 76543210 txchr[7:0]
341 32059l?avr32?01/2012 at32uc3b 21.7.9 baud rate generator register name: brgr access type: read-write offset: 0x20 reset value: 0x00000000 ? fp: fractional part 0: fractional divider is disabled. 1 - 7: baud rate resolution, defined by fp x 1/8. ? cd: clock divider 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ????? fp 15 14 13 12 11 10 9 8 cd[15:8] 76543210 cd[7:0] table 21-21. baud rate in asynchro nous mode (mr.sync is 0) cd over = 0 over = 1 0 baud rate clock disabled 1 to 65535 table 21-22. baud rate in synchronous mode (mr.sync is 1) and spi mode cd baud rate 0 baud rate clock disabled 1 to 65535 baud rate selected clock 16 cd ? --------------------------------------- - = baud rate selected clock 8cd ? --------------------------------------- - = baud rate selected clock cd --------------------------------------- - =
342 32059l?avr32?01/2012 at32uc3b table 21-23. baud rate in iso7816 mode cd baud rate 0 baud rate clock disabled 1 to 65535 baud rate selected clock fi_di_ratio cd ? ------------------------------------------------- =
343 32059l?avr32?01/2012 at32uc3b 21.7.10 receiver time-out register name: rtor access type: read-write offset: 0x24 reset value: 0x00000000 ? to: time-out value 0: the receiver time-out is disabled. 1 - 65535: the receiver time-out is enabled and the time-out delay is to x bit period. note that the size of the to counter is device dependent, see the module configuration section. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 to[15:8] 76543210 to[7:0]
344 32059l?avr32?01/2012 at32uc3b 21.7.11 transmitter timeguard register name: ttgr access type: read-write offset: 0x28 reset value: 0x00000000 ? tg: timeguard value 0: the transmitter timeguard is disabled. 1 - 255: the transmitter timeguard is enabled and the timeguard delay is tg x bit period. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 tg
345 32059l?avr32?01/2012 at32uc3b 21.7.12 fi di ratio register name: fidi access type: read-write offset: 0x40 reset value: 0x00000174 ? fi_di_ratio: fi over di ratio value 0: if iso7816 mode is selected, the baud rate generator does not generate a signal. 1 - 2047: if iso7816 mode is selected, the baud rate is the clock provided on clk divided by fi_di_ratio. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ????? fi_di_ratio[10:8] 76543210 fi_di_ratio[7:0]
346 32059l?avr32?01/2012 at32uc3b 21.7.13 number of errors register name: ner access type: read-only offset: 0x44 reset value: 0x00000000 ? nb_errors: number of errors total number of errors that occurred during an iso781 6 transfer. this register automatically clears when read. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 nb_errors
347 32059l?avr32?01/2012 at32uc3b 21.7.14 irda filter register name: ifr access type: read-write offset: 0x4c reset value: 0x00000000 ? irda_filter: irda filter configures the irda demodulator filter. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 irda_filter
348 32059l?avr32?01/2012 at32uc3b 21.7.15 manchester configuration register name: man access type: read-write offset: 0x50 reset value: 0x30011004 ? drift: drift compensation 0: the usart can not recover from a clock drift. 1: the usart can recover from clock drift (only available in 16x oversampling mode). ? rx_mpol: receiver manchester polarity 0: zeroes are encoded as zero-to-one transitions, an d ones are encoded as a one-to-zero transitions. 1: zeroes are encoded as one-to-zero transitions, an d ones are encoded as a zero-to-one transitions. ? rx_pp: receiver prea mble pattern detected ? rx_pl: receiver preamble length 0: the receiver preamble pattern detection is disabled. 1 - 15: the detected preamble length is rx_pl x bit period ? tx_mpol: transmitter manchester polarity 0: zeroes are encoded as zero-to-one transitions, an d ones are encoded as a one-to-zero transitions. 1: zeroes are encoded as one-to-zero transitions, an d ones are encoded as a zero-to-one transitions. 31 30 29 28 27 26 25 24 ? drift 1 rx_mpol ? ? rx_pp 23 22 21 20 19 18 17 16 ???? rx_pl 15 14 13 12 11 10 9 8 ? ? ? tx_mpol ? ? tx_pp 76543210 ???? tx_pl table 21-24. rx_pp preamble pattern default polari ty assumed (rx_mp ol field not set) 0 0 all_one 0 1 all_zero 10zero_one 11one_zero
349 32059l?avr32?01/2012 at32uc3b ? tx_pp: transmitter preamble pattern ? tx_pl: transmitter preamble length 0: the transmitter preamble pattern generation is disabled 1 - 15: the preamble length is tx_pl x bit period table 21-25. tx_pp preamble pattern default polari ty assumed (tx_mpol field not set) 0 0 all_one 0 1 all_zero 10zero_one 11one_zero
350 32059l?avr32?01/2012 at32uc3b 21.7.16 version register name: version access type: read-only offset: 0xfc reset value: - ?mfn reserved. no functionality associated. ? version version of the module. no functionality associated. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???? mfn 15 14 13 12 11 10 9 8 ???? version[11:8] 76543210 version[7:0]
351 32059l?avr32?01/2012 at32uc3b 21.8 module configuration the specific configuration for each usart instan ce is listed in the following tables.the module bus clocks listed here are connected to the system bus clocks according to the table in the sys- tem bus clock connections section. table 21-26. module configuration feature usart0 usart1 usart2 spi logic implemented implemented implemented rs485 logic not implemented implemented not implemented manchester logic not implemented implemented not implemented modem logic not implemented implemented not implemented irda logic not implemented implemented not implemented fractional baudrate implemented implemented implemented iso7816 not implemented implemented not implemented div888 receiver time-out counter size 8-bits 17-bits 8-bits table 21-27. module clock name module name clock name usart0 clk_usart0 usart1 clk_usart1 usart2 clk_usart2
352 32059l?avr32?01/2012 at32uc3b 22. usb interface (usbb) rev: 3.1.0.1.18 22.1 features ? compatible with the usb 2.0 specification ? supports full (12mbit/s) and low (1.5 mbit/s) speed device and embedded host ? seven pipes/endpoints ? 960 of embedded dual-port ram (dpram) for pipes/endpoints ? up to 2 memory banks per pipe/endpoint (not for control pipe/endpoint) ? flexible pipe/endpoint configuration and management with dedicated dma channels ? on-chip transceivers including pull-ups/pull-downs ? on-chip pad including vbus analog comparator 22.2 overview the universal serial bus (usb) mcu device complies with the universal serial bus (usb) 2.0 specification, but it does not feature hi-speed usb (480 mbit/s). each pipe/endpoint can be configur ed in one of several transfer types. it can be associated with one or more banks of a dual-port ram (dpram) us ed to store the current data payload. if sev- eral banks are used (?ping-pong? mode), then on e dpram bank is read or written by the cpu or the dma while the other is read or written by the usbb core. this feature is mandatory for iso- chronous pipes/endpoints. table 22-1 on page 352 describes the hardware configuration of the usb mcu device. the theoretical maximal pipe/endp oint configuration (1600) exceeds the real dpram size (960). the user needs to be aware of this when configuring pipes/endpoints. to fully use the 960 of dpram, the user could for example use the configuration described in table 22-2 on page 352 . table 22-1. description of usb pipes/endpoints pipe/endpoint mnemonic max. size max. nb. banks dma type 0 pep0 64 bytes 1 n control 1 pep1 64 bytes 2 y isochronous/bulk/interrupt/control 2 pep2 64 bytes 2 y isochronous/bulk/interrupt/control 3 pep3 64 bytes 2 y isochronous/bulk/interrupt/control 4 pep4 64 bytes 2 y isochronous/bulk/interrupt/control 5 pep5 256 bytes 2 y isochronous/bulk/interrupt/control 6 pep6 256 bytes 2 y isochronous/bulk/interrupt/control table 22-2. example of configuration of pipe s/endpoints using the whole dpram pipe/endpoint mnemonic size nb. banks 0 pep0 64 bytes 1 1 pep1 64 bytes 1 2 pep2 64 bytes 1 3 pep3 64 bytes 2
353 32059l?avr32?01/2012 at32uc3b 22.3 block diagram the usbb provides a hardware device to interface a usb link to a data flow stored in a dual-port ram (dpram). the usbb requires a 48mhz 0.25% reference cl ock, which is the us b generic clock gener- ated from one of the power manager oscillator s, optionally through one of the power manager plls. the 48mhz clock is used to generate a 12mhz full-speed (or 1.5 mhz low-speed) bit clock from the received usb differential data and to transmit data according to full- or low-speed usb device tolerance. clock recovery is achieved by a digital phase-locked loop (a dpll, not repre- sented), which complies with th e usb jitter specifications. 4 pep4 64 bytes 2 5 pep5 256 bytes 1 6 pep6 256 bytes 1 table 22-2. example of configuration of pipe s/endpoints using the whole dpram pipe/endpoint mnemonic size nb. banks
354 32059l?avr32?01/2012 at32uc3b figure 22-1. usbb block diagram interrupt controller usb interrupts d- vbus usb_vbof usb i/o controller usb_id d+ user interface power manager usb gclk @ 48 mhz pb dpram usb 2.0 co r e pep allocation dma hsb mux local hsb slave interface hsb1 hsb0 master slave usb clock domain system clock domain 32 bits hsb
355 32059l?avr32?01/2012 at32uc3b 22.4 application block diagram depending on the usb operating mode (device-only, reduced-host modes) and the power source (bus-powered or self-powered), there are different typical hardware implementations. 22.4.1 device mode 22.4.1.1 bus-powered device figure 22-2. bus-powered device application block diagram 22.4.1.2 self-powered device figure 22-3. self-powered device application block diagram usb usb_id d+ d- usb_vbof vbus usb connector id d+ d- vbus gnd 39 1% 3.3 v regulator vdd 39 1% usb usb_id d+ d- usb_vbof vbus usb connector id d+ d- vbus gnd 39 1% 39 1%
356 32059l?avr32?01/2012 at32uc3b 22.4.2 host mode figure 22-4. host application block diagram usb usb_id d+ d- usb_vbof vbus usb connector id d+ d- vbus gnd 5 v dc/dc generator vdd 39 1% 39 1%
357 32059l?avr32?01/2012 at32uc3b 22.5 i/o lines description table 22-3. i/o lines description pin name pin description type active level usb_vbof usb vbus on/off: bus power control port output vbuspo usb_vbus vbus: bus power measurement port input d- data -: differential data line - port input/output d+ data +: differential data line + port input/output usb_id usb identification: mini connector identification port input low: mini-a plug high z: mini-b plug
358 32059l?avr32?01/2012 at32uc3b 22.6 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 22.6.1 i/o lines the usb_vbof and usb_id pins are multiplexed with i/o contro ller lines and may also be multiplexed with lines of other peripherals. in order to use them with the usb, the user must first configure the i/o controller to assign t hem to their usb peripheral functions. if usb_id is used, the i/o controller must be co nfigured to enable the internal pull-up resistor of its pin. if usb_vbof or usb_id is not used by the application, the co rresponding pin can be used for other purposes by the i/o cont roller or by other peripherals. 22.6.2 clocks the clock for the usbb bus interface (clk_u sbb) is generated by the power manager. this clock is enabled at reset, and can be disabled in the power manager. it is recommended to dis- able the usbb before disablin g the clock, to avoid freezing the usbb in an undefined state. the 48mhz usb clock is generated by a dedicated generic clock from the power manager. before using the usb, the user must ensure that the usb generic clock (gclk_usbb) is enabled at 48mhz in the power manager. 22.6.3 interrupts the usbb interrupt request line is connected to the interrupt controller. using the usbb inter- rupt requires the interrupt controller to be programmed first.
359 32059l?avr32?01/2012 at32uc3b 22.7 functional description 22.7.1 usb general operation 22.7.1.1 introduction after a hardware reset, the usbb is disabled. when enabled, the usbb runs either in device mode or in host mode according to the id detection. if the usb_id pin is not connected to ground, the usb_id pin state bit in the general status register (usbsta.id) is set (the internal pull-up resistor of the usb_id pin must be enabled by the i/o controller) and device mode is engaged. the usbsta.id bit is cleared when a low level has been detected on the usb_id pin. host mode is then engaged. 22.7.1.2 power-on and reset figure 22-5 on page 359 describes the usbb main states. figure 22-5. general states after a hardware reset, the usbb is in the reset state. in this state: ? the macro is disabled. th e usbb enable bit in the general control register (usbcon.usbe) is zero. ? the macro clock is stopped in order to mini mize power consumption. the freeze usb clock bit in usbcon (usbon.frzclk) is set. ? the pad is in suspend mode. ? the internal states and registers of the device and host modes are reset. ? the dpram is not cleared and is accessible. ? the usbsta.id bit and the vbus level bit in the ubsta (ubsta.vbus) re flect the states of the usb_id and usb_vbus input pins. ? the otg pad enable (otgpade) bit, the vbus polarity (vbuspo) bit, the frzclk bit, the usbe bit, the usb_id pin enable (uide) bit, the usbb mode (uimod ) bit in usbcon, and the low-speed mode force bit in the device general contro l (udcon.ls) register can be written by software, so that the user can program pads and speed before enabling the macro, but their value is only taken into account once the macro is enabled and unfrozen. device reset usbe = 0 usbe = 1 id = 1 macro off: usbe = 0 clock stopped: frzclk = 1 usbe = 0 host usbe = 0 hw reset usbe = 1 id = 0
360 32059l?avr32?01/2012 at32uc3b after writing a one to usbcon.usbe, the usbb enters the device or the host mode (according to the id detectio n) in idle state. the usbb can be disabled at any time by writin g a zero to usbcon.usbe. in fact, writing a zero to usbcon.usbe acts as a hardware reset, except that the otgpade, vbuspo, frzclk, uide, uimod and, ls bits are not reset. 22.7.1.3 interrupts one interrupt vector is assigned to the usb interface. figure 22-6 on page 361 shows the struc- ture of the usb interrupt system.
361 32059l?avr32?01/2012 at32uc3b figure 22-6. interrupt system see section 22.7.2.17 and section 22.7.3.13 for further details about device and host interrupts. there are two kinds of general interrupts: processi ng, i.e. their generation is part of the normal processing, and exception, i.e. erro rs (not related to cpu exceptions). the processing general interrupts are: usbcon.idte usbsta.idti usbsta.vbusti usbcon.vbuste usbsta.srpi usbcon.srpe usbsta.vberri usbcon.vberre usbsta.bcerri usbcon.bcerre usbsta.roleexi usbcon.roleexe usbsta.hnperri usbcon.hnperre usbsta.stoi usbcon.stoe usb general interrupt usb device interrupt usb host interrupt usb interrupt asynchronous interrupt source udinte.suspe udint.susp udint.sof udinte.sofe udint.eorst udinte.eorste udint.wakeup udinte.wakeupe udint.eorsm udinte.eorsme udint.uprsm udinte.uprsme udint.epxint udinte.epxinte udint.dmaxint udinte.dmaxinte uhinte.dconnie uhint.dconni uhint.ddisci uhinte.ddiscie uhint.rsti uhinte.rstie uhint.rsmedi uhinte.rsmedie uhint.rxrsmi uhinte.rxrsmie uhint.hsofi uhinte.hsofie uhint.hwupi uhinte.hwupie uhint.pxint uhinte.pxinte uhint.dmaxint uhinte.dmaxinte ueconx.txine uestax.txini uestax.rxouti ueconx.rxoute uestax.rxstpi ueconx.rxstpe uestax.underfi ueconx.underfe uestax.nakouti ueconx.nakoute uestax.nakini ueconx.nakine uestax.overfi ueconx.overfe uestax.stalledi ueconx.stallede uestax.crcerri ueconx.crcerre uestax.shortpacket ueconx.shortpackete uestax.nbusybk ueconx.nbusybke upconx.rxine upstax.rxini upstax.txouti upconx.txoute upstax.txstpi upconx.txstpe upstax.underfi upconx.underfie upstax.perri upconx.perre upstax.nakedi upconx.nakede upstax.overfi upconx.overfie upstax.rxstalldi upconx.rxstallde upstax.crcerri upconx.crcerre upstax.shortpacketi upconx.shortpacketie upstax.nbusybk upconx.nbusybke uddmax_control.eot_irq_en uddmax_status.eot_sta uddmax_status.eoch_buff_sta uddmax_control.eobuff_irq_en uddmax_status.desc_ld_sta uddmax_control.desc_ld_irq_en uhdmax_control.eot_irq_en uhdmax_status.eot_sta uhdmax_status.eoch_buff_sta uhdmax_control.eobuff_irq_en uhdmax_status.desc_ld_sta uhdmax_control.desc_ld_irq_en usb device endpoint x interrupt usb host pipe x interrupt usb device dma channel x interrupt usb host dma channel x interrupt
362 32059l?avr32?01/2012 at32uc3b ? the id transition interrupt (idti) ? the vbus transition interrupt (vbusti) ? the role exchange interrupt (roleexi) the exception general interrupts are: ? the vbus error interrupt (vberri) ? the b-connection error interrupt (bcerri) ? the suspend time-out interrupt (stoi) 22.7.1.4 mcu power modes ?run mode in this mode, all mcu clocks can run, including the usb clock. ?idle mode in this mode, the cpu is halted, i.e. the cpu clock is stopped. the idle mode is entered what- ever the state of the usbb. the mcu wakes up on any usb interrupt. ?frozen mode same as the idle mode, except that the hsb module is stopped , so the usb dma, which is an hsb master, can not be used. moreover, the usb dma must be stopped before entering this sleep mode in order to avoid erratic behavior. the mcu wakes up on any usb interrupt. ?standby, stop, deepstop and static modes same as the frozen mode, except that the usb generic clock and other clocks are stopped, so the usb macro is frozen. only the asynchrono us usb interrupt sources can wake up the mcu in these modes (1) . the power manager (pm) may have to be configured to enable asynchro- nous wake up from usb. the usb module must be frozen by writing a one to the frzclk bit. note: 1. when entering a sleep mode deeper or equal to deepstop, the vbus asynchronous interrupt can not be triggered because the bandgap voltage reference is off. thus this interrupt should be disabled (usbcon.vbuste = 0). ?usb clock frozen in the run, idle and frozen mcu modes, the usbb can be frozen when the usb line is in the sus- pend mode, by writing a one to the frzclk bit, what reduces power consumption. in deeper mcu power modes (from standby mode), the usbc must be frozen. in this case, it is still possible to access the following elements, bu t only in run mode: ? the otgpade, vbuspo, frzclk, usbe, uide , uimod and ls bits in the usbcon register ? the dpram (through the usb pipe/endpoint n fifo data (usbfifondata) registers, but not through usb bus transfers which are frozen)
363 32059l?avr32?01/2012 at32uc3b moreover, when frzclk is written to one, only the asynchronous interrupt sources may trigger the usb interrupt: ? the id transition interrupt (idti) ? the vbus transition interrupt (vbusti) ? the wake-up interrupt (wakeup) ? the host wake-up interrupt (hwupi) ?usb suspend mode in peripheral mode, the suspend interrupt bit in the device global interrupt register (udint.susp)indicates that the usb line is in the suspend mode. in this case, the usb data utmi transceiver is automatically set in suspend mode to reduce the consumption. 22.7.1.5 speed control ?device mode when the usbb interface is in device mode, th e speed selection (full- /low-speed) depends on which of d+ and d- is pulled up. the ls bit allows to connect an internal pull-up resistor either on d+ (full-speed mode) or on d- (low-speed mode ). the ls bit shall be written before attaching the device, what can be done by clearing the detach bit in udcon. figure 22-7. speed selection in device mode ?host mode when the usb interface is in host mode, intern al pull-down resistors are connected on both d+ and d- and the interface detects the speed of the connected device, which is reflected by the speed status (speed) field in usbsta. 22.7.1.6 dpram management pipes and endpoints can only be allocated in ascending order (from the pipe/endpoint 0 to the last pipe/endpoint to be allocated). the user shall therefore configure them in the same order. the allocation of a pipe/endpoint n starts when the endpoint memory allocate bit in the endpoint n configuration register (uecfgn.alloc) is written to one. then, the hardware allocates a r pu udcon.detach d+ d- udcon.ls vbus
364 32059l?avr32?01/2012 at32uc3b memory area in the dpram and inserts it betw een the n-1 and n+1 pipes/endpoints. the n+1 pipe/endpoint memory window slides up and its data is lost. note that the following pipe/end- point memory windows (from n+2) do not slide. disabling a pipe, by writing a zero to the pi pe n enable bit in the pipe enable/reset register (uprst.penn), or disabling an endpoint, by writi ng a zero to the endpoint n enable bit in the endpoint enable/reset register (uerst.epenn), resets neither the uecfgn.alloc bit nor its configuration (the pi pe banks (pbk) field, the pipe size (psize) field, the pipe token (pto- ken) field, the pipe type (ptype) field, th e pipe endpoint number (p epnum) field, and the pipe interrupt request frequency (intfrq) field in the pipe n configuration (upcfgn) regis- ter/the endpoint banks (epbk) fi eld, the endpoint size (epsize) field, t he endpoint direction (epdir) field, and the endpoint type (eptype) field in uecfgn). to free its memory, the user shall write a ze ro to the uecfgn.alloc bit. the n+1 pipe/end- point memory window then slides down and its dat a is lost. note that th e following pipe/endpoint memory windows (from n+2) does not slide. figure 22-8 on page 364 illustrates the a llocation and reorganization of the dpram in a typical example. figure 22-8. allocation and reorganization of the dpram 1. the pipes/endpoints 0 to 5 are enabled, configured and allocated in ascending order. each pipe/endpoint then owns a memory area in the dpram. 2. the pipe/endpoint 3 is disabled, but its me mory is kept allocated by the controller. 3. in order to free its memory, its alloc bit is written to zero. the pipe/endpoint 4 mem- ory window slides down, but the pipe/endpoint 5 does not move. 4. if the user chooses to reconfigure the pipe /endpoint 3 with a larg er size, the controller allocates a memory area after the pipe/endpoint 2 memory area and automatically slides up the pipe/endpoint 4 memory windo w. the pipe/endpoint 5 does not move and a memory conflict appears as the memory windows of the pipes/endpoints 4 and 5 overlap. the data of these pipes/endpoints is potentially lost. note that: free memory pep0 pep1 pep2 pep3 pep4 pep5 u(p/e)rst.(e)penn = 1 u(p/e)cfgn.alloc = 1 free memory pep0 pep1 pep2 pep4 pep5 free memory pep0 pep1 pep2 pep4 pep5 pipe/endpoint 3 disabled pipe/endpoint 3 memory freed free memory pep0 pep1 pep2 pep3 (larger size) pep5 pipe/endpoint 3 activated pep4 lost memory pep4 conflict u(p/e)rst.(e)pen3 = 0 pep3 (alloc stays at 1) u(p/e)cfg3.alloc = 0 u(p/e)rst.(e)pen3 = 1 u(p/e)cfg3.alloc = 1 pipes/endpoints 0..5 activated
365 32059l?avr32?01/2012 at32uc3b ? there is no way the data of the pipe/endpoint 0 can be lost (except if it is de-allocated) as memory allocation and de-allocation may affect only higher pipes/endpoints. ? deactivating then reactivating a same pipe/ endpoint with the same configuration only modifies temporarily the cont roller dpram pointer and size for this pipe/endpoint, but nothing changes in the dpram, so higher endp oints seem to not have been moved and their data is preserved as far as nothing has been wr itten or received into them while changing the allocation state of the first pipe/endpoint. ? when the user write a one to the alloc bit, the configuration ok status bit in the endpoint n status register (uestan.cfgok) is set only if the configured size and number of banks are correct compared to their maximal allowed values for the endpoint and to the maximal fifo size (i.e. the dpram size), so the value of cfgok does not consider memory allocation conflicts. 22.7.1.7 pad suspend figure 22-9 on page 365 shows the pad behavior. figure 22-9. pad behavior ? in the idle state, the pad is put in low power consumption mode, i.e., the differential receiver of the usb pad is off, and internal pull-down wit h strong value(15k) are set in both dp/dm to avoid floating lines. ? in the active state, the pad is working. figure 22-10 on page 366 illustrates the pad events le ading to a pad state change. idle active usbe = 1 & detach = 0 & suspend usbe = 0 | detach = 1 | suspend
366 32059l?avr32?01/2012 at32uc3b figure 22-10. pad events the susp bit is set and the wa ke-up interrupt (wakeup) bit in udint is cleared when a usb ?suspend? state has been detected on the usb bus . this event automatically puts the usb pad in the idle state. t he detection of a non-idle event sets wakeup, cl ears susp and wakes up the usb pad. moreover, the pad goes to the idle state if the ma cro is disabled or if the detach bit is written to one. it returns to the active state when usbe is written to one and deta ch is written to zero. 22.7.1.8 plug-in detection the usb connection is detected from the usb_vbus pad. figure 22-11 on page 366 shows the architecture of the plug-in detector. figure 22-11. plug-in detection input block diagram the control logic of the usb_vbus pad outputs two signals: ? the session_valid signal is high when the volt age on the usb_vbus pad is higher than or equal to 1.4v. ? the va_vbus_valid signal is high when the vo ltage on the usb_vbus pad is higher than or equal to 4.4v. in device mode, the usbsta.vbus bit follo ws the session_valid comparator output: ? it is set when the voltage on the usb_vbus pad is higher than or equal to 1.4v. susp suspend detected cleared on wake-up wake-up detected cleared by software to acknowledge the interrupt wakeup pad state active idle active vbusti usbsta usb_vbus vbus usbsta gnd vdd pad logic logic session_valid va_vbus_valid r pu r pd vbus_pulsing vbus_discharge
367 32059l?avr32?01/2012 at32uc3b ? it is cleared when the voltage on the vbus pad is lower than 1.4v. in host mode, the usbsta.vbus bit follows an hysteresis based on session_valid and va_vbus_valid: ? it is set when the voltage on the usb_vbus pad is higher than or equal to 4.4v. ? it is cleared when the voltage on the usb_vbus pad is lower than 1.4v. the vbus transition interrupt (vbusti) bit in usbsta is set on each transition of the usb- sta.vbus bit. the usbsta.vbus bit is ef fective whether the us bb is enabled or not. 22.7.1.9 id detection figure 22-12 on page 367 shows how the id transitions are detected. figure 22-12. id detection input block diagram the usb mode (device or host) can be either detected from the usb_id pin or software selected by writing to the uimod bit, according to the uide bit. this allows the usb_id pin to be used as a general purpose i/o pin even when the usb interface is enabled. by default, the usb_id pin is se lected (uide is writte n to one) and the usbb is in device mode (ubsta.id is one), what corresponds to the ca se where no mini-a plug is connected, i.e. no plug or a mini-b plug is connected and the usb_id pin is kept high by the internal pull-up resis- tor from the i/o controller (which mu st be enabled if usb_id is used). the id transition interrupt (idti) bit in usbsta is set on each transition of the id bit, i.e. when a mini-a plug (host mode) is connected or disconne cted. this does not occur when a mini-b plug (device mode) is connected or disconnected. the usbsta.id bit is ef fective whether the us bb is enabled or not. r pu uimod usbcon usb_id id usbsta vdd uide usbcon 1 0 idti usbsta i/o controller
368 32059l?avr32?01/2012 at32uc3b 22.7.2 usb device operation 22.7.2.1 introduction in device mode, the usbb supports full- and low-speed data transfers. in addition to the default control endpoint, si x endpoints are provided, which can be configured with the types isochronous, bulk or interrupt, as described in table 22-1 on page 352 . the device mode starts in the idle state, so the pad consumption is reduced to the minimum. 22.7.2.2 power-on and reset figure 22-13 on page 368 describes the usbb device mode main states. figure 22-13. device mode states after a hardware reset, the usbb device mode is in the reset state. in this state: ? the macro clock is stopped in order to mini mize power consumption (frzclk is written to one). ? the internal registers of the device mode are reset. ? the endpoint banks are de-allocated. ? neither d+ nor d- is pulled up (detach is written to one). d+ or d- will be pulled up according to the sele cted speed as soon as the detach bit is written to zero and vbus is present. see ?device mode? for further details. when the usbb is enabled (usbe is written to one) in device mode (id is one), its device mode state goes to the idle state with minimal power consumption. this does not require the usb clock to be activated. the usbb device mode can be disa bled and reset at any time by disabling the usbb (by writing a zero to usbe) or when host mode is engaged (id is zero). 22.7.2.3 usb reset the usb bus reset is managed by hardware . it is initiated by a connected host. when a usb reset is detected on the usb line, the following operations are performed by the controller: ? all the endpoints are disabled, exc ept the default control endpoint. reset idle hw reset usbe = 0 | id = 0 usbe = 0 | id = 0 usbe = 1 & id = 1
369 32059l?avr32?01/2012 at32uc3b ? the default control endpoint is reset (see section 22.7.2.4 for more details). ? the data toggle sequence of the default control endpoint is cleared. ? at the end of the reset process, the end of reset (eorst) bit in udint interrupt is set. 22.7.2.4 endpoint reset an endpoint can be reset at any time by writi ng a one to the endpoint n reset (eprstn) bit in the uerst register. this is recommended before using an endpoint upon hardware reset or when a usb bus reset has been received. this resets: ? the internal state machine of this endpoint. ? the receive and transmit bank fifo counters. ? all the registers of this endpoint (uecfgn, uestan, the endpoint n control (ueconn) register), except it s configuration (alloc, epbk, epsi ze, epdir, eptype) and the data toggle sequence (dtseq) field of the uestan register. note that the interrupt sources located in the uestan register are not cleared when a usb bus reset has been received. the endpoint configuration remains active and the e ndpoint is still enabled. the endpoint reset may be associated with a clear of the data toggle sequence as an answer to the clear_feature usb request. this can be achieved by writing a one to the reset data toggle set bit in the endpoint n control set regi ster (ueconnset.rstdts).(this will set the reset data toggle (rstd) bit in ueconn). in the end, the user has to write a zero to t he eprstn bit to complete the reset operation and to start using the fifo. 22.7.2.5 endpoint activation the endpoint is maintained inactive and reset (see section 22.7.2.4 for more details) as long as it is disabled (epenn is written to zero). dtseq is also reset. the algorithm represented on figure 22-14 on page 370 must be followed in order to activate an endpoint.
370 32059l?avr32?01/2012 at32uc3b figure 22-14. endpoint activation algorithm as long as the endpoint is not correctly conf igured (cfgok is zero), the controller does not acknowledge the packets sent by the host to this endpoint. the cfgok bit is set only if the configured size and number of banks are correct compared to their maximal allowed values for the endpoint (see table 22-1 on page 352 ) and to the maximal fifo size (i.e. the dpram size). see section 22.7.1.6 for more details about dpram management. 22.7.2.6 address setup the usb device address is set up according to the usb protocol. ? after all kinds of resets, the usb device address is 0. ? the host starts a setup transact ion with a set_address(addr) request. ? the user write this address to the usb addre ss (uadd) field in udcon, and write a zero to the address enable (adden) bit in udco n, so the actual address is still 0. ? the user sends a zero-length in packet from the control endpoint. ? the user enables the recorded usb device address by writing a one to adden. once the usb device address is configured, the controller filters the packets to only accept those targeting the address stored in uadd. uadd and adden shall not be written all at once. uadd and adden are cleared: ? on a hardware reset. ? when the usbb is disabled (usbe written to zero). ? when a usb reset is detected. when uadd or adden is cleared, the default device address 0 is used. endpoint activation cfgok == 1? error yes endpoint activated enable the endpoint. epenn = 1 test if the endpoint configuration is correct. uecfgn eptype epdir epsize epbk alloc configure the endpoint: - type - direction - size - number of banks allocate the configured dpram banks. no
371 32059l?avr32?01/2012 at32uc3b 22.7.2.7 suspen d and wake-up when an idle usb bus state has been detected for 3 ms, the controller set the suspend (susp) interrupt bit in udint. the user may then write a one to the frzclk bit to reduce power con- sumption. the mcu can also enter the idle or frozen sleep mode to lower again power consumption. to recover from the suspend mode, the user shall wait for the wake-up (wakeup) interrupt bit, which is set when a non-idle event is detected, then write a zero to frzclk. as the wakeup interrupt bit in udint is set when a non-idle event is detected, it can occur whether the controller is in the suspend mode or not. the susp and wakeup interrupts are thus independent of each other except that one bit is cleared when the other is set. 22.7.2.8 detach the reset value of the detach bit is one. it is possible to initiate a devi ce re-enumeration simply by writing a one then a zero to detach. detach acts on the pull-up connec tions of the d+ and d- pads. see ?device mode? for further details. 22.7.2.9 remote wake-up the remote wake-up request (also known as upstream resume) is the only one the device may send on its own initiative, but the device should have beforehand been allowed to by a device_remote_wakeup re quest from the host. ? first, the usbb must ha ve detected a ?suspend? state on the bus, i.e. the remote wake-up request can only be sent after a susp interrupt has been set. ? the user may then write a one to the remote wake-up (rmwkup) bit in udcon to send an upstream resume to the host for a remote wa ke-up. this will automati cally be done by the controller after 5ms of inactivity on the usb bus. ? when the controller sends the upstream resume, the upstream resume (uprsm) interrupt is set and susp is cleared. ? rmwkup is cleared at the end of the upstream resume. ? if the controller detects a valid ?end of resume? signal from the host, the end of resume (eorsm) interrupt is set. 22.7.2.10 stall request for each endpoint, the stall management is performed using: ? the stall request (stallrq) bit in ueconn to initiate a stall request. ? the stalled interrupt (stalledi) bit in uestan is set when a stall handshake has been sent. to answer the next request with a stall handshake, stallrq has to be set by writing a one to the stall request set (stallrqs) bit. a ll following requests will be discarded (rxouti, etc. will not be set) and handshaked with a stal l until the stallrq bit is cleared, what is done when a new setup packet is received (for control endpoints) or when the stall request clear (stallrqc) bit is written to one. each time a stall handshake is sent, the st alledi bit is set by the usbb and the epnint interrupt is set.
372 32059l?avr32?01/2012 at32uc3b ?special considerations for control endpoints if a setup packet is received into a control endpoint for which a stall is requested, the received setup interrupt (rxstpi) bit in uest an is set and stallrq and stalledi are cleared. the setup has to be acked. this management simplifies the enumeration process management. if a command is not sup- ported or contains an error, t he user requests a stall and can return to the main task, waiting for the next setup request. ?stall handshake and retry mechanism the retry mechanism has priority over the stall handshake. a stall hand shake is sent if the stallrq bit is set and if there is no retry required. 22.7.2.11 management of control endpoints ?overview a setup request is always acked. when a new setup packet is received, the rxstpi is set, but not the received out data interrupt (rxouti) bit. the fifo control (fifocon) bi t in ueconn and the read/write allowed (rwall) bit in uestan are irrelevant for control endpoints. t he user shall therefore never use them on these endpoints. when read, their value are always zero. control endpoints are managed using: ? the rxstpi bit which is set when a new set up packet is received and which shall be cleared by firmware to acknowledge the packet and to free the bank. ? the rxouti bit which is set when a new out packet is received and which shall be cleared by firmware to ack nowledge the packet and to free the bank. ? the transmitted in data interrupt (txini) bit which is set when the current bank is ready to accept a new in packet and which shall be cleared by firmware to send the packet. ?control write figure 22-15 on page 373 shows a control write transaction. du ring the status stage, the control- ler will not necessarily send a nak on the first in token: ? if the user knows the exact number of descri ptor bytes that must be read, it can then anticipate the status stage and send a zero-length packet after the next in token. ? or it can read the bytes and wait for the naked in interrupt (nakini) wh ich tells that all the bytes have been sent by the host and that the transaction is now in the status stage.
373 32059l?avr32?01/2012 at32uc3b figure 22-15. control write ?control read figure 22-16 on page 373 shows a control read transaction. the usbb has to manage the simultaneous write requests from the cpu and the usb host. figure 22-16. control read a nak handshake is always generated on the first status stage command. when the controller detects the st atus stage, all the data writt en by the cpu are lost and clear- ing txini has no effect. the user checks if the transmission or the reception is complete. the out retry is always acked. this recepti on sets rxouti and txini. handle this with the following software algorithm: set txini wait for rxouti or txini if rxouti, then clear bit and return if txini, then continue once the out status stage has been receiv ed, the usbb waits for a setup request. the setup request has priority over any other r equest and has to be acked. this means that any other bit should be cleared and the fifo reset when a setup is received. the user has to take care of the fact that the by te counter is reset when a zero-length out packet is received. setup rxstpi rxouti txini usb bus hw sw out hw sw out hw sw in in nak sw data setup status setup rxstpi rxouti txini usb bus hw sw in hw sw in out out nak sw sw hw wr enable host wr enable cpu data setup status
374 32059l?avr32?01/2012 at32uc3b 22.7.2.12 management of in endpoints ?overview in packets are sent by the usb device contro ller upon in requests from the host. all the data can be written which acknowledges or not the bank when it is full. the endpoint must be configured first. the txini bit is set at the same time as fifocon when the current bank is free. this triggers an epnint interrupt if the transmitted in data interrupt enable (txine) bit in ueconn is one. txini shall be cleared by software (by writing a one to the transmitted in data interrupt enable clear bit in the endpoint n control clear regi ster (ueconnclr.txinic)) to acknowledge the interrupt, what ha s no effect on the endpoint fifo. the user then writes into the fifo (see ?usb pipe/endpoint n fifo data register (usbfifon- data)? on page 471 ) and write a one to the fifo control clear (f ifoconc) bit in ueconnclr to clear the fifocon bit. this allows the usbb to send the data. if the in end- point is composed of multiple banks, this al so switches to the next bank. the txini and fifocon bits are updated in accordan ce with the status of the next bank. txini shall always be cleared before clearing fifocon. the rwall bit is set when the current bank is no t full, i.e. the software can write further data into the fifo. figure 22-17. example of an in endpoint with 1 data bank in data (bank 0) ack txini fifocon hw write data to cpu bank 0 sw sw sw sw in nak write data to cpu bank 0
375 32059l?avr32?01/2012 at32uc3b figure 22-18. example of an in endpoint with 2 data banks ?detailed description the data is written, following the next flow: ? when the bank is empty, txini and fifocon are set, what triggers an epnint interrupt if txine is one. ? the user acknowledges the interrupt by clearing txini. ? the user writes the data into the current bank by using the usb pipe/endpoint nfifo data virtual segment (see ?usb pipe/endpoint n fifo data register (usbfifondata)? on page 471 ), until all the data frame is written or the b ank is full (in which case rwall is cleared and the byte count (byct) field in u estan reaches the endpoint size). ? the user allows the controller to send the bank and switches to the next bank (if any) by clearing fifocon. if the endpoint uses several banks, the current one can be written while the previous one is being read by the host. then, when the user clears fifocon, the following bank may already be free and txini is set immediately. an ?abort? stage can be produced when a zero-length out packet is received during an in stage of a control or isochronou s in transaction. the kill in ba nk (killbk) bit in ueconn is used to kill the last written bank. the best way to man age this abort is to apply the algorithm rep- resented on figure 22-19 on page 376 . see ?endpoint n control register? on page 432 to have more details about the killbk bit. in data (bank 0) ack txini fifocon write data to cpu bank 0 sw sw sw sw in data (bank 1) ack write data to cpu bank 1 sw hw write data to cpu bank0
376 32059l?avr32?01/2012 at32uc3b figure 22-19. abort algorithm 22.7.2.13 management of out endpoints ?overview out packets are sent by the host. all the data can be read which acknowledges or not the bank when it is empty. the endpoint must be configured first. the rxouti bit is set at the same time as fifo con when the current bank is full. this triggers an epnint interrupt if the re ceived out data interrupt enab le (rxoute) bit in ueconn is one. rxouti shall be cleared by soft ware (by writing a one to the re ceived out data interrupt clear (rxoutic) bit) to acknowledge the interrupt, what has no effect on the endpoint fifo. the user then reads from the fifo (see ?usb pipe/endpoint n fifo data register (usbfifon- data)? on page 471 ) and clears the fifocon bit to fr ee the bank. if the out endpoint is composed of multiple banks, this also switc hes to the next bank. the rxouti and fifocon bits are updated in accordance with the status of the next bank. rxouti shall always be clea red before clearing fifocon. the rwall bit is set when the current bank is no t empty, i.e. the software can read further data from the fifo. endpoint abort abort done abort is based on the fact that no bank is busy, i.e., that nothing has to be sent disable the txini interrupt. eprstn = 1 nbusybk == 0? yes txinec = 1 no killbks = 1 killbk == 1? yes kill the last written bank. wait for the end of the procedure no
377 32059l?avr32?01/2012 at32uc3b figure 22-20. example of an out endpoint with one data bank figure 22-21. example of an out endpoint with two data banks ?detailed description the data is read, following the next flow: ? when the bank is full, rxouti and fifocon ar e set, what triggers an epnint interrupt if rxoute is one. ? the user acknowledges the interrupt by writing a one to rxoutic in order to clear rxouti. ? the user can read the byte count of the curren t bank from byct to know how many bytes to read, rather than polling rwall. ? the user reads the data from the current bank by using the usbfifondata register (see ?usb pipe/endpoint n fifo data register (usbfifondata)? on page 471 ), until all the expected data frame is read or the bank is empty (in which case rwall is cleared and byct reaches zero). ? the user frees the bank and switches to the next bank (if any) by clearing fifocon. if the endpoint uses several banks, the current one can be read while the following one is being written by the host. then, when the user clear s fifocon, the following bank may already be ready and rxouti is set immediately. out data (bank 0) ack rxouti fifocon hw out data (bank 0) ack hw sw sw sw read data from cpu bank 0 read data from cpu bank 0 nak out data (bank 0) ack rxouti fifocon hw out data (bank 1) ack sw sw read data from cpu bank 0 hw sw read data from cpu bank 1
378 32059l?avr32?01/2012 at32uc3b 22.7.2.14 underflow this error exists only for isochronous in/out endpoints. it set t he underflow interrupt (underfi) bit in uestan, what triggers an epni nt interrupt if the underflow interrupt enable (underfe) bit is one. an underflow can occur during in stage if the host attempts to read from an empty bank. a zero- length packet is then auto matically sent by the usbb. an underflow can not occur during out stage on a cpu action, since the user may read only if the bank is not empty (rxouti is one or rwall is one). an underflow can also occur during out stage if the host sends a packet while the bank is already full. typically, the cpu is not fast enough. the packet is lost. an underflow can not occur during in stage on a cp u action, since the user may write only if the bank is not full (txini is one or rwall is one). 22.7.2.15 overflow this error exists for all endpoint types. it set the overflow interrupt (overfi) bit in uestan, what triggers an epnint interr upt if the overflow interrup t enable (overfe) bit is one. an overflow can occur during out stage if the host attempts to write into a bank that is too small for the packet. the packet is acknowledged and th e rxouti bit is set as if no overflow had occurred. the bank is filled with all the first bytes of the packet that fit in. an overflow can not occur during in stage on a cpu action, since the user may write only if the bank is not full (txini is one or rwall is one). 22.7.2.16 crc error this error exists only for isochronous out endp oints. it set the crc error interrupt (crcerri) bit in uestan, what triggers an epnint interr upt if the crc error inte rrupt enable (crcerre) bit is one. a crc error can occur during out stage if the usbb detects a corrupted received packet. the out packet is stored in the bank as if no crc error had occurred (rxouti is set). 22.7.2.17 interrupts see the structure of the usb device interrupt system on figure 22-6 on page 361 . there are two kinds of device interrupts: proces sing, i.e. their generati on is part of the normal processing, and exception, i.e. erro rs (not related to cpu exceptions). ?global interrupts the processing device global interrupts are: ? the suspend (susp) interrupt ? the start of frame (sof) interrupt with no frame number crc error (the frame number crc error (fncerr) bit in the device fram e number (udfnum) register is zero) ? the end of reset (eorst) interrupt ? the wake-up (wakeup) interrupt ? the end of resume (eorsm) interrupt
379 32059l?avr32?01/2012 at32uc3b ? the upstream resume (uprsm) interrupt ? the endpoint n (epnint) interrupt ? the dma channel n (dmanint) interrupt the exception device global interrupts are: ? the start of frame (sof) interrupt wit h a frame number crc error (fncerr is one) ?endpoint interrupts the processing device endpoint interrupts are: ? the transmitted in data interrupt (txini) ? the received out data interrupt (rxouti) ? the received setup interrupt (rxstpi) ? the short packet (shortpacket) interrupt ? the number of busy ba nks (nbusybk) interrupt the exception device endpoint interrupts are: ? the underflow interrupt (underfi) ? the naked out interrupt (nakouti) ? the naked in interrupt (nakini) ? the overflow interrupt (overfi) ? the stalled interrupt (stalledi) ? the crc error interrupt (crcerri) ?dma interrupts the processing device dma interrupts are: ? the end of usb transfer status (eotsta) interrupt ? the end of channel buffer status (eochbuffsta) interrupt ? the descriptor loaded status (descldsta) interrupt there is no exception device dma interrupt.
380 32059l?avr32?01/2012 at32uc3b 22.7.3 usb host operation 22.7.3.1 description of pipes for the usbb in host mode, the term ?pipe? is used instead of ?end point? (used in device mode). a host pipe corresponds to a device endpoint, as described by the figure 22-22 on page 380 from the usb specification. figure 22-22. usb communication flow in host mode, the usbb associates a pipe to a device endpoint, considering the device configu- ration descriptors. 22.7.3.2 power-on and reset figure 22-23 on page 380 describes the usbb host mode main states. figure 22-23. host mode states after a hardware reset, the usbb hos t mode is in the reset state. when the usbb is enabled (usbe is one) in host mode (id is zero ), its host mode state goes to the idle state. in this state, the controller waits for device connection with minimal power con- ready idle device disconnection device connection macro off clock stopped device disconnection suspend sofe = 1 sofe = 0
381 32059l?avr32?01/2012 at32uc3b sumption. the usb pad should be in the idle st ate. once a device is connected, the macro enters the ready state, wh at does not require the usb clock to be activated. the controller enters the suspend state when the usb bus is in a ?suspend? state, i.e., when the host mode does not generate the ?start of fr ame (sof)?. in this stat e, the usb consumption is minimal. the host mode exit s the suspend state wh en starting to generate the sof over the usb line. 22.7.3.3 device detection a device is detected by the usbb host mode w hen d+ or d- is no longer tied low, i.e., when the device d+ or d- pull-up resistor is connected. to enable this detection, the host controller has to provide the vbus power supply to the device by setting the vbusrq bit (by writing a one to the vbusrqs bit). the device disconnection is detected by the host controller when both d+ and d- are pulled down. 22.7.3.4 usb reset the usbb sends a usb bus reset when the user write a one to the send usb reset bit in the host general control register (uhcon.reset). the usb reset sent interrupt bit in the host global interrupt register (uhint .rsti) is set when the usb reset has been sent. in this case, all the pipes are disabled and de-allocated. if the bus was previously in a ?suspend? state (t he start of frame generation enable (sofe) bit in uhcon is zero), the usbb automatically switc hes it to the ?resume? state, the host wake- up interrupt (hwupi) bit in uhint is set and th e sofe bit is set in order to generate sofs immediately after the usb reset. 22.7.3.5 pipe reset a pipe can be reset at any time by writing a one to the pipe n reset (prstn) bit in the uprst register. this is recommended before using a pipe upon hardware reset or when a usb bus reset has been sen t. this resets: ? the internal state machine of this pipe ? the receive and transmit bank fifo counters ? all the registers of this pipe (upcfgn, upst an, upconn), except its configuration (alloc, pbk, psize, ptoken, ptype, pepnum, intfrq in upcfgn) and its data toggle sequence field in the pipe n status register (upstan.dtseq). the pipe configuration remains acti ve and the pipe is still enabled. the pipe reset may be associated with a clea r of the data toggle s equence. this can be achieved by setting the reset data toggle bit in the pipe n control r egister (upconn.rstdt) (by writing a one to the reset data toggle set bit in the pipe n control set register (upconnset.rstdts)). in the end, the user has to write a zero to the prstn bit to complete the reset operation and to start using the fifo. 22.7.3.6 pipe activation the pipe is maintained inactive and reset (see section 22.7.3.5 for more details) as long as it is disabled (penn is zero). the data toggle sequence field (dtseq) is also reset.
382 32059l?avr32?01/2012 at32uc3b the algorithm represented on figure 22-24 on page 382 must be followed in order to activate a pipe. figure 22-24. pipe activation algorithm as long as the pipe is not correctly configured (upstan.cfgok is zero), the controller can not send packets to the device through this pipe. the upstan.cfgok bit is set only if the config ured size and number of banks are correct com- pared to their maximal allowed values for the pipe (see table 22-1 on page 352 ) and to the maximal fifo size (i.e. the dpram size). see section 22.7.1.6 for more details about dpram management. once the pipe is correctly co nfigured (upstan.cfgok is zero ), only the ptoken and intfrq fields can be written by software. intfr q is meaningless for non-interrupt pipes. when starting an enumeration, the user gets the device descriptor by sending a get_descriptor usb request. this descripto r contains the maximal packet size of the device default control endpoint (bmaxpacketsize0 ) and the user re-configures the size of the default control pipe with this size parameter. 22.7.3.7 address setup once the device has answered the first host reques ts with the default device address 0, the host assigns a new address to the device. the host c ontroller has to send an usb reset to the device and to send a set_address(addr) setup request with the new address to be used by the device. once this setup transaction is over, th e user writes the new address into the usb host address for pipe n field in the usb host devi ce address register (uhaddr.uhaddrpn). all following requests, on all pipes, will be performed using this new address. when the host controller sends an usb reset, t he uhaddrpn field is reset by hardware and the following host requests will be performe d using the default device address 0. pipe activation cfgok == 1? error yes pipe activated enable the pipe. penn = 1 test if the pipe configuration is correct. upcfgn intfrq pepnum ptype ptoken psize pbk alloc configure the pipe: - interrupt request frequency - endpoint number - type - size - number of banks allocate the configured dpram banks. no
383 32059l?avr32?01/2012 at32uc3b 22.7.3.8 remote wake-up the controller host mode enters the suspend state when the uhcon.sofe bit is written to zero. no more ?start of frame? is sent on t he usb bus and the usb device enters the suspend state 3ms later. the device awakes the host by sending an upstream resume (remote wake-up feature). when the host controller detects a non-idle stat e on the usb bus, it set the host wake-up inter- rupt (hwupi) bit in uhint. if the non-idle bus state corresponds to an upstream resume (k state), the upstream resume received interrupt (rxrsmi) bit in uhint is set. the user has to generate a downstream resume within 1ms and for at least 20ms by writing a one to the send usb resume (resume) bit in uhcon. it is ma ndatory to write a one to uhcon.sofe before writing a one to uhcon.resume to enter the ready state, else uhcon.resume will have no effect. 22.7.3.9 management of control pipes a control transaction is composed of three stages: ? setup ? data (in or out) ? status (out or in) the user has to change the pipe token according to each stage. for the control pipe, and only for it, each token is assigned a specific initial data toggle sequence: ? setup: data0 ?in: data1 ? out: data1 22.7.3.10 management of in pipes in packets are sent by the usb device contro ller upon in requests from the host. all the data can be read which acknowledges or not the bank when it is empty. the pipe must be configured first. when the host requires data from the device, the user has to select beforehand the in request mode with the in request mode bit in the pi pe n in request register (upinrqn.inmode): ? when inmode is written to zero, the usbb will perform (inrq + 1) in requests before freezing the pipe. ? when inmode is written to one, the usbb will perform in reque sts endlessly when the pipe is not frozen by the user. the generation of in requests starts when the pipe is unfrozen (the pipe freeze (pfreeze) field in upconn is zero). the received in data interrupt (r xini) bit in upstan is set at the same time as the fifo con- trol (fifocon) bit in upconn when the current bank is full. this triggers a pnint interrupt if the received in data interrupt enable (rxine) bit in upconn is one. rxini shall be cleared by software (by writing a one to the received in data interrupt clear bit in the pipe n control clear register(upconnclr .rxinic)) to acknowledge the interrupt, what has no effect on the pipe fifo.
384 32059l?avr32?01/2012 at32uc3b the user then reads from the fifo (see ?usb pipe/endpoint n fifo data register (usbfifon- data)? on page 471 ) and clears the fifocon bit (by writ ing a one to the fifo control clear (fifoconc) bit in upconnclr) to free the bank. if the in pipe is composed of multiple banks, this also switches to the next bank. the rxini and fifocon bits are updated in accordance with the status of the next bank. rxini shall always be clear ed before clearing fifocon. the read/write allowed (rwall) bit in upstan is set when the current bank is not empty, i.e., the software can read further data from the fifo. figure 22-25. example of an in pipe with 1 data bank figure 22-26. example of an in pipe with 2 data banks 22.7.3.11 management of out pipes out packets are sent by the host. all the data can be written which acknowledges or not the bank when it is full. the pipe must be configured and unfrozen first. the transmitted out data interrupt (txouti) bit in upstan is set at the same time as fifo- con when the current bank is free. this triggers a pnint interrupt if the transmitted out data interrupt enable (txoute) bit in upconn is one. in data (bank 0) ack rxini fifocon hw in data (bank 0) ack hw sw sw sw read data from cpu bank 0 read data from cpu bank 0 in data (bank 0) ack rxini fifocon hw in data (bank 1) ack sw sw read data from cpu bank 0 hw sw read data from cpu bank 1
385 32059l?avr32?01/2012 at32uc3b txouti shall be cleared by software (by writi ng a one to the transmitted out data interrupt clear (txoutic) bit in upconncl r) to acknowledge the interrup t, what has no effect on the pipe fifo. the user then writes into the fifo (see ?usb pipe/endpoint n fifo data register (usbfifon- data)? on page 471 ) and clears the fifocon bit to allow the usbb to send the data. if the out pipe is composed of multiple banks, this also switches to the next bank. the txouti and fifocon bits are updated in accordan ce with the status of the next bank. txouti shall always be cleared before clearing fifocon. the upstan.rwall bit is set when the current bank is not full, i.e., the software can write fur- ther data into the fifo. note that if the user decides to switch to the suspend state (by writing a zero to the uhcon.sofe bit) while a bank is ready to be sent, the usbb automatica lly exits this state and the bank is sent. figure 22-27. example of an out pipe with one data bank figure 22-28. example of an out pipe with two data banks and no bank switching delay out data (bank 0) ack txouti fifocon hw write data to cpu bank 0 sw sw sw sw out write data to cpu bank 0 out data (bank 0) ack txouti fifocon write data to cpu bank 0 sw sw sw sw write data to cpu bank 1 sw hw write data to cpu bank0 out data (bank 1) ack
386 32059l?avr32?01/2012 at32uc3b figure 22-29. example of an out pipe with two data banks and a bank switching delay 22.7.3.12 crc error this error exists only for isochronous in pi pes. it set the crc error interrupt (crcerri) bit, what triggers a pnint interrupt if then the crc error interrupt enable (crcerre) bit in upconn is one. a crc error can occur during in stage if the us bb detects a corrupted received packet. the in packet is stored in the bank as if no crc error had occurred (rxini is set). 22.7.3.13 interrupts see the structure of the usb host interrupt system on figure 22-6 on page 361 . there are two kinds of host interrupts: processing, i.e. their generation is part of the normal pro- cessing, and exception, i.e. errors (not related to cpu exceptions). ?global interrupts the processing host global interrupts are: ? the device connection interrupt (dconni) ? the device disconnection interrupt (ddisci) ? the usb reset sent interrupt (rsti) ? the downstream resume sent interr upt (rsmedi) ? the upstream resume received interrupt (rxrsmi) ? the host start of frame interrupt (hsofi) ? the host wake-up interrupt (hwupi) ? the pipe n interrupt (pnint) ? the dma channel n interrupt (dmanint) there is no exception host global interrupt. ?pipe interrupts the processing host pipe interrupts are: ? the received in data interrupt (rxini) out data (bank 0) ack txouti fifocon write data to cpu bank 0 sw sw sw sw out data (bank 1) ack write data to cpu bank 1 sw hw write data to cpu bank0
387 32059l?avr32?01/2012 at32uc3b ? the transmitted out data interrupt (txouti) ? the transmitted setup interrupt (txstpi) ? the short packet interrupt (shortpacketi) ? the number of busy ba nks (nbusybk) interrupt the exception host pipe interrupts are: ? the underflow interrupt (underfi) ? the pipe error interrupt (perri) ? the naked in terrupt (nakedi) ? the overflow interrupt (overfi) ? the received stalled interrupt (rxstalldi) ? the crc error interrupt (crcerri) ?dma interrupts the processing host dma interrupts are: ? the end of usb transfer status (eotsta) interrupt ? the end of channel buffer status (eochbuffsta) interrupt ? the descriptor loaded status (descldsta) interrupt there is no exception host dma interrupt.
388 32059l?avr32?01/2012 at32uc3b 22.7.4 usb dma operation 22.7.4.1 introduction usb packets of any length may be transferred when required by the usbb. these transfers always feature sequential addressi ng. these two characteristics mean that in case of high usbb throughput, both hsb ports will benefit from ?incrementing burst of unspecified length? since the average access latency of hsb slaves can then be reduced. the dma uses word ?incrementing burst of unspec ified length? of up to 256 beats for both data transfers and channel descriptor loading. a burs t may last on the hsb busses for the duration of a whole usb packet transfer, unless otherwise br oken by the hsb arbitration or the hsb 1kbyte boundary crossing. packet data hsb bursts may be locked on a dma buffer basis for drastic overall hsb bus band- width performance boost with paged memories. th is is because these memories row (or bank) changes, which are very clock-cycle consuming, will then likely not occur or occur once instead of dozens of times during a single big usb packet dma transfer in case other hsb masters address the memory. this means up to 128 words single cycle unbroken hsb bursts for bulk pipes/endpoints and 256 words si ngle cycle unbroken bursts fo r isochronous pipes/endpoints. this maximal burst length is th en controlled by the lowest programmed usb pipe/endpoint size (psize/epsize) and the channel byte length (chbytelength) field in the device dma channel n control (uddmancontrol) register. the usbb average throughput may be up to near ly 12mbit/s. its average access latency decreases as burst length increases due to the zero wait-state side effect of unchanged pipe/endpoint. word access allows reducing the hsb bandwidth required for the usb by four compared to native byte access. if at least 0 wa it-state word burst capability is also provided by the other dma hsb bus slaves, each of both dma hsb busses need less than 1.1% bandwidth allocation for full usb bandwidth usage at 33mhz, and less than 0.6% at 66mhz.
389 32059l?avr32?01/2012 at32uc3b figure 22-30. example of dma chained list 22.7.4.2 dma channel descriptor the dma channel transfer descriptor is loaded from the memory. be careful with the alig nment of this buffer. the structure of the dma channel transfer de scriptor is defined by three parameters as described below: ?offset 0: ? the address must be aligned: 0xxxxx0 ? dma channel n next descriptor ad dress register: dmannxtdescaddr ?offset 4: ? the address must be aligned: 0xxxxx4 ? dma channel n hsb address register: dmanaddr ?offset 8: ? the address must be aligned: 0xxxxx8 ? dma channel n control register: dmancontrol 22.7.4.3 programming a chanel: each dma transfer is unidirectionnal. direction de pends on the type of the associated endpoint (in or out). three registers, the uddmannextdesc , the uddmanaddr an d uddmancontrol need to be programmed to set up wether single or multiple transfer is used. the following example refers to out endpoint. for in endpoint, the programming is symmetric. data buffer 1 data buffer 2 data buffer 3 memory area transfer descriptor next descriptor address hsb address control transfer descriptor transfer descriptor usb dma channel x registers (current transfer descriptor) next descriptor address hsb address control null status next descriptor address hsb address control next descriptor address hsb address control
390 32059l?avr32?01/2012 at32uc3b ?single-block transfer programming example for out transfer : the following sequence may be used: ? configure the targerted endpoint (source) as ou t type, and set the automatic bank switching for this endpoint in the uecfgn regi ster to handle mu ltiple out packet. ? write the starting destination ad dress in the uddmanaddr register. ? there is no need to program the uddmannextdesc register. ? program the channel byte length in the uddm ancontrol register. ? program the uddmancontrol according to row 2 as shown in figure 22-6 on page 439 to set up a single block transfer. the uddmanstatus.chen bit is set indicating that the dma channel is enable. as soon as an out packet is stored inside the endpoint, the uddmanstatus.chactive bit is set to one, indicating that the dma channel is transfering data from the endpoint to the desti- nation address until the endpoint is empty or t he channel byte length is reached. once the endpoint is empty, the uddman status.chactive bit is cleared. once the dma channel is completed (i.e : the channel byte length is reached), after one or mul- tiple processed out packet, the uddmancontrol.chen bit is cleared. as a consequence, the uddmanstatus.chen bit is also cleare d, and the uddmanstat us.eochbuffsta bit is set indicating a end of dma channel. if t he uddmancontrol.dmaenden bit was set, the last endpoint bank will be properly released even if there are some resi dual datas inside, i.e: out packet truncation at the end of dma buffer when the dm a channel byte lenght is not an integral multiple of the endpoint size. ?programming example for single-block dma tran sfer with automatic closure for out transfer : the idea is to automatically close the dma transf er at the end of the out transaction (received short packet). the following sequence may be used: ? configure the targerted endpoint (source) as ou t type, and set the automatic bank switching for this endpoint in the uecfgn regi ster to handle mu ltiple out packet. ? write the starting destination ad dress in the uddmanaddr register. ? there is no need to program the uddmannextdesc register. ? program the channel byte length in the uddm ancontrol register. ? set the buffcloseinen bit in the uddmancontrol register. ? program the uddmancontrol according to row 2 as shown in figure 22-6 on page 439 to set up a single block transfer. as soon as an out packet is stored inside the endpoint, the uddmanstatus.chactive bit is set to one, indicating that the dma channel is transfering data from the endpoint to the desti- nation address until the endpoint is empty. once the endpoint is empty, the uddmanstatus.chactive bit is cleared. after one or multiple processed out packet, t he dma channel is completed after sourcing a short packet. then, the uddmanco ntrol.chen bit is cleared. as a consequence, after a few cycles latency, the uddmanstatus.chen bi t is also cleared, and the uddmansta- tus.eotsta bit is set indicating that the dma was closed by a end of usb transaction.
391 32059l?avr32?01/2012 at32uc3b ?programming example for multi-block dma transfer : run and link at end of buffer the idea is to run first a single block transfer followed automatically by a linked list of dma. the following sequence may be used: ? configure the targerted endpoint (source) as ou t type, and set the automatic bank switching for this endpoint in the uecfgn regi ster to handle mu ltiple out packet. ? set up the chain of linked list of descripor in memory. each descriptor is composed of 3 items : channel next descriptor address, channel dest ination address and channel control. the last descriptor should be programmed according to row 2 as shown in figure 22-6 on page 439 . ? write the starting destination ad dress in the uddmanaddr register. ? program the uddmannextdesc register. ? program the channel byte length in the uddm ancontrol register. ? optionnaly set the buffcloseinen bi t in the uddmancontrol register. ? program the uddmancontrol according to row 4 as shown in figure 22-6 on page 439 . the uddmanstatus.chen bit is set indicating that the dma channel is enable. as soon as an out packet is stored inside the endpoint, the uddmanstatus.chactive bit is set to one, indicating that the dma channel is transfering data from the endpoint to the desti- nation address until the endpoint is empty or t he channel byte length is reached. once the endpoint is empty, the uddman status.chactive bit is cleared. once the first dma channel is completed (i.e : the channel byte length is reached), after one or multiple processed out packet, the uddmancontrol.chen bit is cleared. as a conse- quence, the uddmanstatus.chen bit is also cleared, and the uddmanstatus.eochbuffsta bit is set indicating a end of dma channel. if the uddman- control.dmaenden bit was set, the last endpoint b ank will be properly released even if there are some residual datas inside, i.e: out packet truncation at the end of dma buffer when the dma channel byte lenght is not an integral multiple of t he endpoint size. note that the uddmancontrol.ldnxtch bit remains to one i ndicating that a linked descriptor will be loaded. once the new descriptor is loaded from the uddmannextdesc memory address, the uddm- anstatus.descldsta bit is set, and the uddma ncontrol register is updated from the memory. as a consequence, the uddmanstat us.chen bit is set, and the uddmansta- tus.chactive is set as soon as the endpoint is ready to be sourced by the dma (received out data packet). this sequence is repeated until a last linked de scriptor is processed. the last descriptor is detected according to row 2 as shown in figure 22-6 on page 439 . at the end of the last descriptor, the uddmancontrol.chen bit is cleared. as a conse- quence, after a few cycles latency, the uddmanstatus.chen bit is also cleared. ?programming example for multi-block dma transfer : load next descriptor now the idea is to directly run first a linked list of dma. the following sequence may be used: the following sequence may be used: ? configure the targerted endpoint (source) as ou t type, and set the automatic bank switching for this endpoint in the uecfgn regi ster to handle mu ltiple out packet.
392 32059l?avr32?01/2012 at32uc3b ? set up the chain of linked list of descripor in memory. each descriptor is composed of 3 items : channel next descriptor address, channel dest ination address and channel control. the last descriptor should be programmed according to row 2 as shown in figure 22-6 on page 439 . ? program the uddmannextdesc register. ? program the uddmancontrol according to row 3 as shown in figure 22-6 on page 439 . the uddmanstatus.chen bit is 0 and the uddmanstatus.ldnxtchd escen is set indi- cating that the dma channel is pending until the endpoint is ready (received out packet). as soon as an out packet is stored inside the endpoint, the uddmanstatus.chactive bit is set to one. then after a few cycle latency, the new descriptor is loaded from the memory and the uddmanstatus.descldsta is set. at the end of this dma (for instance when the channel byte length has reached 0), the uddmancontrol.chen bit is cleared, and then the uddmanstatus.chen bit is also cleared. if the uddmanco ntrol.ldnxtch value is one, a new descriptor is loaded. this sequence is repeated until a last linked de scriptor is processed. the last descriptor is detected according to row 2 as shown in figure 22-6 on page 439 . at the end of the last descriptor, the uddmancontrol.chen bit is cleared. as a conse- quence, after a few cycles latency, the uddmanstatus.chen bit is also cleared.
393 32059l?avr32?01/2012 at32uc3b 22.8 user interface table 22-4. usbb register memory map offset register name access reset value 0x0000 device general control register udcon read/write 0x00000100 0x0004 device global interrupt register udint read-only 0x00000000 0x0008 device global interrupt clear register udintclr write-only 0x00000000 0x000c device global interrupt set register udintset write-only 0x00000000 0x0010 device global interrupt enable register udinte read-only 0x00000000 0x0014 device global interrupt enable clear register udinteclr write-only 0x00000000 0x0018 device global interrupt enable set register udinteset write-only 0x00000000 0x001c endpoint enable/reset register uerst read/write 0x00000000 0x0020 device frame number register udfnum read-only 0x00000000 0x0100 endpoint 0 configuration register uecfg0 read/write 0x00002000 0x0104 endpoint 1 configuration register uecfg1 read/write 0x00002000 0x0108 endpoint 2 configuration register uecfg2 read/write 0x00002000 0x010c endpoint 3 configuration register uecfg3 read/write 0x00002000 0x0110 endpoint 4 configuration register uecfg4 read/write 0x00002000 0x0114 endpoint 5 configuration register uecfg5 read/write 0x00002000 0x0118 endpoint 6 configuration register uecfg6 read/write 0x00002000 0x0130 endpoint 0 status register uesta0 read-only 0x00000100 0x0134 endpoint 1 status register uesta1 read-only 0x00000100 0x0138 endpoint 2 status register uesta2 read-only 0x00000100 0x013c endpoint 3 status register uesta3 read-only 0x00000100 0x0140 endpoint 4 status register uesta4 read-only 0x00000100 0x0144 endpoint 5 status register uesta5 read-only 0x00000100 0x0148 endpoint 6 status register uesta6 read-only 0x00000100 0x0160 endpoint 0 status clear register uesta0clr write-only 0x00000000 0x0164 endpoint 1 status clear register uesta1clr write-only 0x00000000 0x0168 endpoint 2 status clear register uesta2clr write-only 0x00000000 0x016c endpoint 3 status clear register uesta3clr write-only 0x00000000 0x0170 endpoint 4 status clear register uesta4clr write-only 0x00000000 0x0174 endpoint 5 status clear register uesta5clr write-only 0x00000000 0x0178 endpoint 6 status clear register uesta6clr write-only 0x00000000 0x017c endpoint 7 status clear register uesta7clr write-only 0x00000000 0x0190 endpoint 0 status set register uesta0set write-only 0x00000000 0x0194 endpoint 1 status set register uesta1set write-only 0x00000000 0x0198 endpoint 2 status set register uesta2set write-only 0x00000000 0x019c endpoint 3 status set register uesta3set write-only 0x00000000
394 32059l?avr32?01/2012 at32uc3b 0x01a0 endpoint 4 status set register uesta4set write-only 0x00000000 0x01a4 endpoint 5 status set register uesta5set write-only 0x00000000 0x01a8 endpoint 6 status set register uesta6set write-only 0x00000000 0x01ac endpoint 7 status set register uesta7set write-only 0x00000000 0x01c0 endpoint 0 control register uecon0 read-only 0x00000000 0x01c4 endpoint 1 control register uecon1 read-only 0x00000000 0x01c8 endpoint 2 control register uecon2 read-only 0x00000000 0x01cc endpoint 3 control register uecon3 read-only 0x00000000 0x01d0 endpoint 4 control register uecon4 read-only 0x00000000 0x01d4 endpoint 5 control register uecon5 read-only 0x00000000 0x01d8 endpoint 6 control register uecon6 read-only 0x00000000 0x01dc endpoint 7 control register uecon7 read-only 0x00000000 0x01f0 endpoint 0 control set register uecon0set write-only 0x00000000 0x01f4 endpoint 1 control set register uecon1set write-only 0x00000000 0x01f8 endpoint 2 control set register uecon2set write-only 0x00000000 0x01fc endpoint 3 control set register uecon3set write-only 0x00000000 0x0200 endpoint 4 control set register uecon4set write-only 0x00000000 0x0204 endpoint 5 control set register uecon5set write-only 0x00000000 0x0208 endpoint 6 control set register uecon6set write-only 0x00000000 0x020c endpoint 7 control set register uecon7set write-only 0x00000000 0x0220 endpoint 0 control clear register uecon0clr write-only 0x00000000 0x0224 endpoint 1 control clear register uecon1clr write-only 0x00000000 0x0228 endpoint 2 control clear register uecon2clr write-only 0x00000000 0x022c endpoint 3 control clear register uecon3clr write-only 0x00000000 0x0230 endpoint 4 control clear register uecon4clr write-only 0x00000000 0x0234 endpoint 5 control clear register uecon5clr write-only 0x00000000 0x0238 endpoint 6 control clear register uecon6clr write-only 0x00000000 0x023c endpoint 7 control clear register uecon7clr write-only 0x00000000 0x0310 device dma channel 1 next descriptor address register uddma1 nextdesc read/write 0x00000000 0x0314 device dma channel 1 hsb address register uddma1 addr read/write 0x00000000 0x0318 device dma channel 1 control register uddma1 control read/write 0x00000000 0x031c device dma channel 1 status register uddma1 status read/write 0x00000000 0x0320 device dma channel 2 next descriptor address register uddma2 nextdesc read/write 0x00000000 table 22-4. usbb register memory map offset register name access reset value
395 32059l?avr32?01/2012 at32uc3b 0x0324 device dma channel 2 hsb address register uddma2 addr read/write 0x00000000 0x0328 device dma channel 2 control register uddma2 control read/write 0x00000000 0x032c device dma channel 2 status register uddma2 status read/write 0x00000000 0x0330 device dma channel 3 next descriptor address register uddma3 nextdesc read/write 0x00000000 0x0334 device dma channel 3 hsb address register uddma3 addr read/write 0x00000000 0x0338 device dma channel 3 control register uddma3 control read/write 0x00000000 0x033c device dma channel 3 status register uddma3 status read/write 0x00000000 0x0340 device dma channel 4 next descriptor address register uddma4 nextdesc read/write 0x00000000 0x0344 device dma channel 4 hsb address register uddma4 addr read/write 0x00000000 0x0348 device dma channel 4 control register uddma4 control read/write 0x00000000 0x034c device dma channel 4 status register uddma4 status read/write 0x00000000 0x0350 device dma channel 5 next descriptor address register uddma5 nextdesc read/write 0x00000000 0x0354 device dma channel 5 hsb address register uddma5 addr read/write 0x00000000 0x0358 device dma channel 5 control register uddma5 control read/write 0x00000000 0x035c device dma channel 5 status register uddma5 status read/write 0x00000000 0x0360 device dma channel 6 next descriptor address register uddma6 nextdesc read/write 0x00000000 0x0364 device dma channel 6 hsb address register uddma6 addr read/write 0x00000000 0x0368 device dma channel 6 control register uddma6 control read/write 0x00000000 0x036c device dma channel 6 status register uddma6 status read/write 0x00000000 0x0400 host general control register uhcon read/write 0x00000000 0x0404 host global interrupt register uhint read-only 0x00000000 0x0408 host global interrupt clear register uhintclr write-only 0x00000000 0x040c host global interrupt set register uhintset write-only 0x00000000 0x0410 host global interrupt enable register uhinte read-only 0x00000000 table 22-4. usbb register memory map offset register name access reset value
396 32059l?avr32?01/2012 at32uc3b 0x0414 host global interrupt enable clear register uhinteclr write-only 0x00000000 0x0418 host global interrupt enable set register uhinteset write-only 0x00000000 0x0041c pipe enable/reset register uprst read/write 0x00000000 0x0420 host frame number register uhfnum read/write 0x00000000 0x0424 host address 1 register uhaddr1 read/write 0x00000000 0x0428 host address 2 register uhaddr2 read/write 0x00000000 0x0500 pipe 0 configuration register upcfg0 read/write 0x00000000 0x0504 pipe 1 configuration register upcfg1 read/write 0x00000000 0x0508 pipe 2 configuration register upcfg2 read/write 0x00000000 0x050c pipe 3 configuration register upcfg3 read/write 0x00000000 0x0510 pipe 4 configuration register upcfg4 read/write 0x00000000 0x0514 pipe 5 configuration register upcfg5 read/write 0x00000000 0x0518 pipe 6 configuration register upcfg6 read/write 0x00000000 0x0530 pipe 0 status register upsta0 read-only 0x00000000 0x0534 pipe 1 status register upsta1 read-only 0x00000000 0x0538 pipe 2 status register upsta2 read-only 0x00000000 0x053c pipe 3 status register upsta3 read-only 0x00000000 0x0540 pipe 4 status register upsta4 read-only 0x00000000 0x0544 pipe 5 status register upsta5 read-only 0x00000000 0x0548 pipe 6 status register upsta6 read-only 0x00000000 0x0560 pipe 0 status clear register upsta0clr write-only 0x00000000 0x0564 pipe 1 status clear register upsta1clr write-only 0x00000000 0x0568 pipe 2 status clear register upsta2clr write-only 0x00000000 0x056c pipe 3 status clear register upsta3clr write-only 0x00000000 0x0570 pipe 4 status clear register upsta4clr write-only 0x00000000 0x0574 pipe 5 status clear register upsta5clr write-only 0x00000000 0x0578 pipe 6 status clear register upsta6clr write-only 0x00000000 0x0590 pipe 0 status set register upsta0set write-only 0x00000000 0x0594 pipe 1 status set register upsta1set write-only 0x00000000 0x0598 pipe 2 status set register upsta2set write-only 0x00000000 0x059c pipe 3 status set register upsta3set write-only 0x00000000 0x05a0 pipe 4 status set register upsta4set write-only 0x00000000 0x05a4 pipe 5 status set register upsta5set write-only 0x00000000 0x05a8 pipe 6 status set register upsta6set write-only 0x00000000 0x05c0 pipe 0 control register upcon0 read-only 0x00000000 0x05c4 pipe 1 control register upcon1 read-only 0x00000000 table 22-4. usbb register memory map offset register name access reset value
397 32059l?avr32?01/2012 at32uc3b 0x05c8 pipe 2 control register upcon2 read-only 0x00000000 0x05cc pipe 3 control register upcon3 read-only 0x00000000 0x05d0 pipe 4 control register upcon4 read-only 0x00000000 0x05d4 pipe 5 control register upcon5 read-only 0x00000000 0x05d8 pipe 6 control register upcon6 read-only 0x00000000 0x05dc pipe 7 control register upcon7 read-only 0x00000000 0x05f0 pipe 0 control set register upcon0set write-only 0x00000000 0x05f4 pipe 1 control set register upcon1set write-only 0x00000000 0x05f8 pipe 2 control set register upcon2set write-only 0x00000000 0x05fc pipe 3 control set register upcon3set write-only 0x00000000 0x0600 pipe 4 control set register upcon4set write-only 0x00000000 0x0604 pipe 5 control set register upcon5set write-only 0x00000000 0x0608 pipe 6 control set register upcon6set write-only 0x00000000 0x0620 pipe 0 control clear register upcon0clr write-only 0x00000000 0x0624 pipe 1 control clear register upcon1clr write-only 0x00000000 0x0628 pipe 2 control clear register upcon2clr write-only 0x00000000 0x062c pipe 3 control clear register upcon3clr write-only 0x00000000 0x0630 pipe 4 control clear register upcon4clr write-only 0x00000000 0x0634 pipe 5 control clear register upcon5clr write-only 0x00000000 0x0638 pipe 6 control clear register upcon6clr write-only 0x00000000 0x0650 pipe 0 in request register upinrq0 read/write 0x00000000 0x0654 pipe 1 in request register upinrq1 read/write 0x00000000 0x0658 pipe 2 in request register upinrq2 read/write 0x00000000 0x065c pipe 3 in request register upinrq3 read/write 0x00000000 0x0660 pipe 4 in request register upinrq4 read/write 0x00000000 0x0664 pipe 5 in request register upinrq5 read/write 0x00000000 0x0668 pipe 6 in request register upinrq6 read/write 0x00000000 0x0680 pipe 0 error register uperr0 read/write 0x00000000 0x0684 pipe 1 error register uperr1 read/write 0x00000000 0x0688 pipe 2 error register uperr2 read/write 0x00000000 0x068c pipe 3 error register uperr3 read/write 0x00000000 0x0690 pipe 4 error register uperr4 read/write 0x00000000 0x0694 pipe 5 error register uperr5 read/write 0x00000000 0x0698 pipe 6 error register uperr6 read/write 0x00000000 0x0710 host dma channel 1 next descriptor address register uhdma1 nextdesc read/write 0x00000000 table 22-4. usbb register memory map offset register name access reset value
398 32059l?avr32?01/2012 at32uc3b 0x0714 host dma channel 1 hsb address register uhdma1 addr read/write 0x00000000 0x0718 host dma channel 1 control register uhdma1 control read/write 0x00000000 0x071c host dma channel 1 status register uhdma1 status read/write 0x00000000 0x0720 host dma channel 2 next descriptor address register uhdma2 nextdesc read/write 0x00000000 0x0724 host dma channel 2 hsb address register uhdma2 addr read/write 0x00000000 0x0728 host dma channel 2 control register uhdma2 control read/write 0x00000000 0x072c host dma channel 2 status register uhdma2 status read/write 0x00000000 0x0730 host dma channel 3 next descriptor address register uhdma3 nextdesc read/write 0x00000000 0x0734 host dma channel 3 hsb address register uhdma3 addr read/write 0x00000000 0x0738 host dma channel 3 control register uhdma3 control read/write 0x00000000 0x073c host dma channel 3status register uhdma3 status read/write 0x00000000 0x0740 host dma channel 4 next descriptor address register uhdma4 nextdesc read/write 0x00000000 0x0744 host dma channel 4 hsb address register uhdma4 addr read/write 0x00000000 0x0748 host dma channel 4 control register uhdma4 control read/write 0x00000000 0x074c host dma channel 4 status register uhdma4 status read/write 0x00000000 0x0750 host dma channel 5 next descriptor address register uhdma5 nextdesc read/write 0x00000000 0x0754 host dma channel 5 hsb address register uhdma5 addr read/write 0x00000000 0x0758 host dma channel 5 control register uhdma5 control read/write 0x00000000 0x075c host dma channel 5 status register uhdma5 status read/write 0x00000000 0x0760 host dma channel 6 next descriptor address register uhdma6 nextdesc read/write 0x00000000 0x0764 host dma channel 6 hsb address register uhdma6 addr read/write 0x00000000 0x0768 host dma channel 6 control register uhdma6 control read/write 0x00000000 table 22-4. usbb register memory map offset register name access reset value
399 32059l?avr32?01/2012 at32uc3b note: 1. the reset values are device specific. please refer to the module configuration section at the end of this chapter. 0x076c host dma channel 6 status register uhdma6 status read/write 0x00000000 0x0800 general control register usbcon read/write 0x03004000 0x0804 general status register usbsta read-only 0x00000400 0x0808 general status clear regi ster usbstaclr write-only 0x00000000 0x080c general status set regi ster usbstaset writ e-only 0x00000000 0x0818 ip version register uvers read-only - (1) 0x081c ip features register ufeatures read-only - (1) 0x0820 ip pb address size register uaddrsize read-only - (1) 0x0824 ip name register 1 uname1 read-only - (1) 0x0828 ip name register 2 uname2 read-only - (1) 0x082c usb finite state machine status register usbfsm read-only 0x00000009 table 22-5. usb hsb memory map offset register name access reset value 0x00000 - 0x0fffc pipe/endpoint 0 fifo data register usb fifo0data read/write undefined 0x10000 - 0x1fffc pipe/endpoint 1 fifo data register usb fifo1data read/write undefined 0x20000 - 0x2fffc pipe/endpoint 2 fifo data register usb fifo2data read/write undefined 0x30000 - 0x3fffc pipe/endpoint 3 fifo data register usb fifo3data read/write undefined 0x40000 - 0x4fffc pipe/endpoint 4 fifo data register usb fifo4data read/write undefined 0x50000 - 0x5fffc pipe/endpoint 5 fifo data register usb fifo5data read/write undefined 0x60000 - 0x6fffc pipe/endpoint 6 fifo data register usb fifo6data read/write undefined table 22-4. usbb register memory map offset register name access reset value
400 32059l?avr32?01/2012 at32uc3b 22.8.1 usb general registers 22.8.1.1 general control register name: usbcon access type: read/write offset: 0x0800 reset value: 0x03004000 ? uimod: usbb mode this bit has no effect when uide is one (usb_id input pin activated). 0: the module is in usb host mode. 1: the module is in usb device mode. this bit can be written even if usbe is zero or frzclk is one. disabling the usbb (by writing a zero to the usbe bit) does not reset this bit. ? uide: usb_id pin enable 0: the usb mode (device/host) is selected from the uimod bit. 1: the usb mode (device/host) is selected from the usb_id input pin. this bit can be written even if usbe is zero or frzclk is one. disabling the usbb (by writing a zero to the usbe bit) does not reset this bit. ? unlock: timer access unlock 1: the timpage and timvalue fields are unlocked. 0: the timpage and timvalue fields are locked. the timpage and timvalue fields can always be read, whatever the value of unlock. ? timpage: timer page this field contains the page value to access a special timer register. ? timvalue: timer value this field selects the timer value that is written to the special time register selected by timpage. see section 22.7.1.8 for details. ? usbe: usbb enable writing a zero to this bit will reset the usbb, disable the u sb transceiver and, disable the u sbb clock inputs. unless explicit ly stated, all registers then will become read-only and will be reset. 1: the usbb is enabled. 0: the usbb is disabled. 31 30 29 28 27 26 25 24 ------uimoduide 23 22 21 20 19 18 17 16 - unlock timpage - - timvalue 15 14 13 12 11 10 9 8 usbe frzclk vbuspo otgpade vbushwc 76543210 stoe roleexe bcerre vberre vbuste idte
401 32059l?avr32?01/2012 at32uc3b this bit can be written even if frzclk is one. ? frzclk: freeze usb clock 1: the clock input are disabled (the resume detection is still ac tive).this reduces power consumption. unless explicitly stated , all registers then become read-only. 0: the clock inputs are enabled. this bit can be written even if usbe is ze ro. disabling the usbb (by writ ing a zero to the usbe bit) does not reset this bit, b ut this freezes the clock inputs whatever its value. ? vbuspo: vbus polarity 1: the usb_vbof output signal is inverted (active low). 0: the usb_vbof output signal is in its default mode (active high). to be generic. may be useful to control an external vbus power module. this bit can be written even if usbe is zero or frzclk is one. disabling the usbb (by writing a zero to the usbe bit) does not reset this bit. ? otgpade: otg pad enable 1: the otg pad is enabled. 0: the otg pad is disabled. this bit can be written even if usbe is zero or frzclk is one. disabling the usbb (by writing a zero to the usbe bit) does not reset this bit. ? vbushwc: vbus hardware control 1: the hardware control over the usb_vbof output pin is disabled. 0: the hardware control over the usb_vbof output pin is enabled. the usbb resets the usb_vbof output pin when a vbus problem occurs. ? stoe: suspend time-out interrupt enable 1: the suspend time-out interrupt (stoi) is enabled. 0: the suspend time-out interrupt (stoi) is disabled. ? roleexe: role exchan ge interrupt enable 1: the role exchange interrupt (roleexi) is enabled. 0: the role exchange interrupt (roleexi) is disabled. ? bcerre: b-connection error interrupt enable 1: the b-connection error interrupt (bcerri) is enabled. 0: the b-connection error interrupt (bcerri) is disabled. ? vberre: vbus error interrupt enable 1: the vbus error interru pt (vberri) is enabled. 0: the vbus error interrupt (vberri) is disabled. ? vbuste: vbus transition interrupt enable 1: the vbus transition interrupt (vbusti) is enabled. 0: the vbus transition interrupt (vbusti) is disabled. ? idte: id transition interrupt enable 1: the id transition interrupt (idti) is enabled. 0: the id transition interrupt (idti) is disabled.
402 32059l?avr32?01/2012 at32uc3b 22.8.1.2 general status register register name: usbsta access type: read-only offset: 0x0804 reset value: 0x00000400 ? speed: speed status this field is set according to the controller speed mode.. ? vbus: vbus level this bit is set when the vbus line level is high. this bit is cleared when the vbus line level is low. this bit can be used in either device or host mode to monitor the usb bus connection state of the application. ? id: usb_id pin state this bit is cleared when the usb_id level is low, even if usbe is zero. this bit is set when the usb_id le vel is high, event if usbe is zero. ? vbusrq: vbus request this bit is set when the usbstaset .vbusrqs bit is written to one. this bit is cleared when the usbstaclr.vbusrqc bit is written to one or when a vbus error occurs and vbushwc is zero. 1: the usb_vbof output pin is driven high to enable the vbus power supply generation. 0: the usb_vbof output pin is driven low to disable the vbus power supply generation. this bit shall only be used in host mode. ? stoi: suspend time-out interrupt this bit is set when a time-out error (more than 200ms) has been detected after a suspend. this triggers a usb interrupt if stoe is one. this bit is cleared when the ubstaclr.stoic bit is written to one. this bit shall only be used in host mode. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - speed vbus id vbusrq - 76543210 stoi roleexi bcerri vberri vbusti idti speed speed status 0 0 full-speed mode 1 0 low-speed mode x1reserved
403 32059l?avr32?01/2012 at32uc3b ? roleexi: role ex change interrupt this bit is set when the usbb has successfully switched its mo de because of an negotiation (host to device or device to host). this triggers a usb interr upt if roleexe is one. this bit is cleared when the ubst aclr.roleexic bit is written to one. ? bcerri: b-connection error interrupt this bit is set when an error occurs during the b-connection. this triggers a usb interrupt if bcerre is one. this bit is cleared when the ubstaclr.bcerric bit is written to one. this bit shall only be used in host mode. ? vberri: vbus error interrupt this bit is set when a vbus drop has been detect ed. this triggers a usb interrupt if vberre is one. this bit is cleared when the ubstaclr.vberric bit is written to one. this bit shall only be used in host mode. if a vbus problem occurs, then the vberri interrupt is generated even if the usbb d oes not go to an error state because of vbushwc is one. ? vbusti: vbus transition interrupt this bit is set when a transition (high to low, low to high) has been detected on the usb_vbus pad. this triggers an usb interrupt if vbuste is one. this bit is cleared when the ubstaclr.vbustic bit is written to one. this interrupt is generated even if the clock is frozen by the frzclk bit. ? idti: id transition interrupt this bit is set when a transition (high to low, low to high) has been detected on the usb_id input pin. this triggers an usb interrupt if idte is one. this bit is cleared when the ubstaclr.idtic bit is written to one. this interrupt is gen erated even if the clock is frozen by the frzclk bit or pad is disable by usbcon.otgpade or the usbb module is disabled by usbcon.usbe.
404 32059l?avr32?01/2012 at32uc3b 22.8.1.3 general status clear register register name: usbstaclr access type: write-only offset: 0x0808 read value: 0x00000000 writing a one to a bit in this register will clear the corresponding bit in ubsta. writing a zero to a bit in this register has no effect. this bit always reads as zero. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ------vbusrqc- 76543210 stoic roleexic bcerric vberric vbustic idtic
405 32059l?avr32?01/2012 at32uc3b 22.8.1.4 general status set register register name: usbstaset access type: write-only offset: 0x080c read value: 0x00000000 writing a one to a bit in this register will set the corresponding bit in ubsta, what may be useful for test or debug purposes. writing a zero to a bit in this register has no effect. this bit always reads as zero. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ------vbusrqs- 76543210 stois roleexis bcerris vberris vbustis idtis
406 32059l?avr32?01/2012 at32uc3b 22.8.1.5 version register register name: uvers access type: read-only offset: 0x0818 read value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
407 32059l?avr32?01/2012 at32uc3b 22.8.1.6 features register register name: ufeatures access type: read-only offset: 0x081c read value: - ? bytewritedpram: dpram byte-write capability 1: the dpram is natively byte-write capable. 0: the dpram byte write lane s have shadow logic implement ed in the usbb ip interface. ? fifomaxsize: maximal fifo size this field indicates the maximal fifo size, i.e., the dpram size: 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 bytewrite dpram fifomaxsize dmafifoworddepth 76543210 dmabuffe rsize dmachannelnbr eptnbrmax fifomaxsize maximal fifo size 0 0 0 < 256 bytes 0 0 1 < 512 bytes 0 1 0 < 1024 bytes 0 1 1 < 2048 bytes 1 0 0 < 4096 bytes 1 0 1 < 8192 bytes 1 1 0 < 16384 bytes 1 1 1 >= 16384 bytes
408 32059l?avr32?01/2012 at32uc3b ? dmafifoworddepth: dma fifo depth in words this field indicates the dma fifo depth controller in words: ? dmabuffersize: dma buffer size 1: the dma buffer size is 24bits. 0: the dma buffer size is 16bits. ? dmachannelnbr: number of dma channels this field indicates the number of hardware-implemented dma channels: ? eptnbrmax: maximal numb er of pipes/endpoints this field indicates the number of hardware-implemented pipes/endpoints: dmafifoworddepth dma fifo depth in words 000016 00011 00102 ... 111115 dmachannelnbr number of dma channels 000reserved 0011 0102 ... 1117 eptnbrmax maximal number of pipes/endpoints 000016 00011 00102 ... 111115
409 32059l?avr32?01/2012 at32uc3b 22.8.1.7 address size register register name: uaddrsize access type: read-only offset: 0x0820 read value: - ? uaddrsize: ip pb address size this field indicates the size of the pb addr ess space reserved for the usbb ip interface. 31 30 29 28 27 26 25 24 uaddrsize[31:24] 23 22 21 20 19 18 17 16 uaddrsize[23:16] 15 14 13 12 11 10 9 8 uaddrsize[15:8] 76543210 uaddrsize[7:0]
410 32059l?avr32?01/2012 at32uc3b 22.8.1.8 name register 1 register name: uname1 access type: read-only offset: 0x0824 read value: - ? uname1: ip name part one this field indicates the first part of the ascii-encoded name of the usbb ip. 31 30 29 28 27 26 25 24 uname1[31:24] 23 22 21 20 19 18 17 16 uname1[23:16] 15 14 13 12 11 10 9 8 uname1[15:8] 76543210 uname1[7:0]
411 32059l?avr32?01/2012 at32uc3b 22.8.1.9 name register 2 register name: uname2 access type: read-only offset: 0x0828 read value: ? uname2: ip name part two this field indicates the second part of the ascii-encoded name of the usbb ip. 31 30 29 28 27 26 25 24 uname2[31:24] 23 22 21 20 19 18 17 16 uname2[23:16] 15 14 13 12 11 10 9 8 uname2[15:8] 76543210 uname2[7:0]
412 32059l?avr32?01/2012 at32uc3b 22.8.1.10 finite state machine status register register name: usbfsm access type: read-only offset: 0x082c read value: 0x00000009 ? drdstate this field indicates the state of the usbb. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - - drdstate drdstate description 0 a_idle state: this is the start state for a-devices (when the id pin is 0) 1 a_wait_vrise: in this state, the a-device waits for the voltage on vbus to rise above the a- device vbus valid threshold (4.4 v). 2 a_wait_bcon: in this state, the a-device waits for the b-device to signal a connection. 3 a_host: in this state, the a-device that operates in host mode is operational. 4 a_suspend: the a-device operating as a host is in the suspend mode. 5 a_peripheral: the a-device operates as a peripheral. 6 a_wait_vfall: in this state, the a-device waits for the voltage on vbus to drop below the a- device session valid threshold (1.4 v). 7 a_vbus_err: in this state, the a-device waits for recovery of the over-current condition that caused it to enter this state. 8 a_wait_discharge: in this state, the a-device waits for the data usb line to discharge (100 us). 9 b_idle: this is the start state for b-device (when the id pin is 1). 10 b_peripheral: in this state, the b-device acts as the peripheral. 11 b_wait_begin_hnp: in this state, the b-device is in suspend mode and waits until 3 ms before initiating the hnp protocol if requested. 12 b_wait_discharge: in this state, the b-device wa its for the data usb line to discharge (100 us) before becoming host.
413 32059l?avr32?01/2012 at32uc3b 13 b_wait_acon: in this state, the b-device waits for the a-device to signal a connect before becoming b-host. 14 b_host: in this state, the b-device acts as the host. 15 b_srp_init: in this state, the b-device atte mpts to start a session using the srp protocol. drdstate description
414 32059l?avr32?01/2012 at32uc3b 22.8.2 usb device registers 22.8.2.1 device general control register register name: udcon access type: read/write offset: 0x0000 reset value: 0x00000100 ? ls: low-speed mode force 1: the low-speed mode is active. 0: the full-speed mode is active. this bit can be written even if usbe is zero or frzclk is one. disabling the usbb (by writing a zero to the usbe bit) does not reset this bit. ? rmwkup: remote wake-up writing a one to this bit will send an upstream resume to the host for a remote wake-up. writing a zero to this bit has no effect. this bit is cleared when the usbb receive a usb reset or once the upstream resume has been sent. ? detach: detach writing a one to this bit will physically detach the device (disconnect internal pull-up resistor from d+ and d-). writing a zero to this bit will reconnect the device. ? adden: address enable writing a one to this bit will activate the uadd field (usb address). writing a zero to this bit has no effect. this bit is cleared when a usb reset is received. ? uadd: usb address this field contains the device address. this field is cleared when a usb reset is received. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - - ls - - rmwkup detach 76543210 adden uadd
415 32059l?avr32?01/2012 at32uc3b 22.8.2.2 device global interrupt register register name: udint access type: read-only offset: 0x0004 reset value: 0x00000000 ? dmanint: dma channel n interrupt this bit is set when an interrupt is triggered by the dma channel n. this triggers a usb interrupt if dmaninte is one. this bit is cleared when the uddmanstatus interrupt source is cleared. ? epnint: endpoint n interrupt this bit is set when an interrupt is triggered by the endpoint n (uestan, ueconn). this triggers a usb interrupt if epninte is one. this bit is cleared when the interrupt source is serviced. ? uprsm: upstream resume interrupt this bit is set when the usbb sends a resume signal called ?ups tream resume?. this triggers a usb interrupt if uprsme is one. this bit is cleared when the udintclr.uprsmc bit is written to one to acknowledge the interrupt (usb clock inputs must be enabled before). ? eorsm: end of resume interrupt this bit is set when the usbb detects a va lid ?end of resume? signal initiated by the host. this triggers a usb interrupt if eorsme is one. this bit is cleared when the udintclr.eorsmc bit is written to one to acknowledge the interrupt. ? wakeup: wake-up interrupt this bit is set when the usbb is reactivat ed by a filtered non-idle signal from the li nes (not by an upstream resume). this triggers an interrupt if wakeupe is one. this bit is cleared when the ud intclr.wakeupc bit is written to one to acknow ledge the interrupt (usb clock inputs must be enabled before). this bit is cleared when the suspend (susp) interrupt bit is set. this interrupt is generated even if the clock is frozen by the frzclk bit. ? eorst: end of reset interrupt this bit is set when a usb ?end of reset? has been detected. this triggers a usb interrupt if eorste is one. this bit is cleared when the udintclr.eorstc bit is written to one to acknowledge the interrupt. 31 30 29 28 27 26 25 24 - dma6int dma5int dma4int dma3int dma2int dma1int - 23 22 21 20 19 18 17 16 - - - - - ep6int ep5int ep4int 15 14 13 12 11 10 9 8 ep3int ep2int ep1int ep0int - - - - 76543210 - uprsm eorsm wakeup eorst sof - susp
416 32059l?avr32?01/2012 at32uc3b ? sof: start of frame interrupt this bit is set when a usb ?start of frame? pid (sof) has been de tected (every 1 ms). this triggers a usb interrupt if sofe is one. the fnum field is updated. this bit is cleared when the udintclr.sofc bit is written to one to acknowledge the interrupt. ? susp: suspend interrupt this bit is set when a usb ?suspend? idle bus state has been det ected for 3 frame periods (j state for 3 ms). this triggers a usb interrupt if suspe is one. this bit is cleared when the udintclr.suspc bit is written to one to acknowledge the interrupt. this bit is cleared when the wake-up (wakeup) interrupt bit is set.
417 32059l?avr32?01/2012 at32uc3b 22.8.2.3 device global in terrupt clear register register name: udintclr access type: write-only offset: 0x0008 read value: 0x00000000 writing a one to a bit in this register will clear the corresponding bit in udint. writing a zero to a bit in this register has no effect. this bit always reads as zero. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - uprsmc eorsmc wakeupc eorstc sofc - suspc
418 32059l?avr32?01/2012 at32uc3b 22.8.2.4 device global interrupt set register register name: udintset access type: write-only offset: 0x000c read value: 0x00000000 writing a one to a bit in this register will set the corresponding bit in udint, what may be useful for test or debug purposes. writing a zero to a bit in this register has no effect. this bit always reads as zero. 31 30 29 28 27 26 25 24 - dma6ints dma5ints dma4ints d ma3ints dma2ints dma1ints - 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - uprsms eorsms wakeups eorsts sofs - susps
419 32059l?avr32?01/2012 at32uc3b 22.8.2.5 device global interrupt enable register register name: udinte access type: read-only offset: 0x0010 reset value: 0x00000000 1: the corresponding interrupt is enabled. 0: the corresponding interrupt is disabled. a bit in this register is set when the corresponding bit in udinteset is written to one. a bit in this register is cleared when the corresponding bit in udinteclr is written to one. 31 30 29 28 27 26 25 24 - dma6inte dma5inte dma4inte d ma3inte dma2inte dma1inte - 23 22 21 20 19 18 17 16 - - - - - ep6inte ep5inte ep4inte 15 14 13 12 11 10 9 8 ep3inte ep2inte ep1inte ep0inte - - - - 76543210 - uprsme eorsme wakeupe eorste sofe - suspe
420 32059l?avr32?01/2012 at32uc3b 22.8.2.6 device global inte rrupt enable clear register register name: udinteclr access type: write-only offset: 0x0014 read value: 0x00000000 writing a one to a bit in this register will clear the corresponding bit in udinte. writing a zero to a bit in this register has no effect. this bit always reads as zero. 31 30 29 28 27 26 25 24 - dma6intec dma5intec dma4intec dma3intec dma2intec dma1intec - 23 22 21 20 19 18 17 16 - - - - - ep6intec ep5intec ep4intec 15 14 13 12 11 10 9 8 ep3intec ep2intec ep1intec ep0intec - - - - 76543210 - uprsmec eorsmec wakeupec eorstec sofec - suspec
421 32059l?avr32?01/2012 at32uc3b 22.8.2.7 device global in terrupt enable set register register name: udinteset access type: write-only offset: 0x0018 read value: 0x00000000 writing a one to a bit in this register will set the corresponding bit in udinte. writing a zero to a bit in this register has no effect. this bit always reads as zero. 31 30 29 28 27 26 25 24 - dma6intes dma5intes dma4intes dma3intes dma2intes dma1intes - 23 22 21 20 19 18 17 16 - - - - - ep6intes ep5intes ep4intes 15 14 13 12 11 10 9 8 ep3intes ep2intes ep1intes ep0intes - - - - 76543210 - uprsmes eorsmes wakeupes eorstes sofes - suspes
422 32059l?avr32?01/2012 at32uc3b 22.8.2.8 endpoint enable/reset register register name: uerst access type: read/write offset: 0x001c reset value: 0x00000000 ? eprstn: endpoint n reset writing a one to this bit will reset the endpoint n fifo prior to any other operation, upon hardware reset or when a usb bus reset has been received. this resets the endpoint n registers (uecfgn, uestan, ueconn) but not the endpoint configuration (alloc, epbk, epsize, epdir, eptype). all the endpoint mechanism (fifo counter, reception, transmission, etc.) is reset apart from the data toggle sequence field (dtseq) which can be cleared by setting the rs tdt bit (by writing a one to the rstdts bit). the endpoint configuration remains active and the endpoint is still enabled. writing a zero to this bit will complete the reset operation and start using the fifo. this bit is cleared upon receiving a usb reset. ? epenn: endpoint n enable 1: the endpoint n is enabled. 0: the endpoint n is disabled, what forces the endpoint n state to inactive (no answer to usb requests) and resets the endpoint n registers (uecfgn, uestan, ueconn ) but not the endpoint c onfiguration (alloc, epbk, epsize, epdir, eptype). 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - eprst6 eprst5 eprst4 epr st3 eprst2 eprst1 eprst0 15 14 13 12 11 10 9 8 -------- 76543210 - epen6 epen5 epen4 epen3 epen2 epen1 epen0
423 32059l?avr32?01/2012 at32uc3b 22.8.2.9 device frame number register register name: udfnum access type: read-only offset: 0x0020 reset value: 0x00000000 ? fncerr: frame number crc error this bit is set when a corrupted frame number is received. th is bit and the sof interrupt bit are updated at the same time. this bit is cleared upon receiving a usb reset. ? fnum: frame number this field contains the 11-bit frame number information. it is provided in the last received sof packet. this field is cleared upon receiving a usb reset. fnum is updated even if a corrupted sof is received. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 fncerr - fnum[10:5] 76543210 fnum[4:0] - - -
424 32059l?avr32?01/2012 at32uc3b 22.8.2.10 endpoint n configuration register register name: uecfgn, n in [0..6] access type: read/write offset: 0x0100 + (n * 0x04) reset value: 0x00000000 ? eptype: endpoint type this field shall be written to select the endpoint type: this field is cleared upon receiving a usb reset. ? autosw: automatic switch this bit is cleared upon receiving a usb reset. 1: the automatic bank switching is enabled. 0: the automatic bank switching is disabled. ? epdir: endpoint direction this bit is cleared upon receiving a usb reset. 1: the endpoint direction is in (nor for control endpoints). 0: the endpoint direction is out. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - - eptype - autosw epdir 76543210 - epsize epbk alloc - eptype endpoint type 0 0 control 0 1 isochronous 10bulk 1 1 interrupt
425 32059l?avr32?01/2012 at32uc3b ? epsize: endpoint size this field shall be written to select the size of each endpoint bank. the maximum size of each endpoint is specified in table 22- 1 on page 352 . this field is cleared upon receiving a usb reset (except for the endpoint 0). ? epbk: endpoint banks this field shall be written to select the number of banks for the endpoint: for control endpoints, a single-bank endpoint (0b00) shall be selected. this field is cleared upon receiving a usb reset (except for the endpoint 0). ? alloc: endpoint memory allocate writing a one to this bit will allocate the endpoint memory. the user should check the cfgok bit to know whether the allocation of this endpoint is correct. writing a zero to this bit will free the endpoint memory. this bit is cleared upon receiving a usb reset (except for the endpoint 0). epsize endpoint size 0 0 0 8 bytes 0 0 1 16 bytes 0 1 0 32 bytes 0 1 1 64 bytes 1 0 0 128 bytes 1 0 1 256 bytes 1 1 0 512 bytes epbk endpoint banks 0 0 1 (single-bank endpoint) 0 1 2 (double-bank endpoint) 1 0 3 (triple-bank endpoint) if supported (see table 22-1 on page 352 ). 11reserved
426 32059l?avr32?01/2012 at32uc3b 22.8.2.11 endpoint n status register register name: uestan, n in [0..6] access type: read-only 0x0100 offset: 0x0130 + (n * 0x04) reset value: 0x00000100 ? byct: byte count this field is set with the byte count of the fifo. for in endpoints, incremented after each byte written by the software into the endpoint and decremented after each byte sent to the host. for out endpoints, incremented after each byte received from t he host and decremented after each byte read by the software from the endpoint. this field may be updated one clock cycle after the rwall bit changes, so the user should not poll this field as an interrupt b it. ? cfgok: configuration ok status this bit is updated when the alloc bit is written to one. this bit is set if the endpoint n numb er of banks (epbk) and size (epsize) are correct compared to the maximal allowed number of banks and size for this endpoint and to the maximal fifo size (i.e. the dpram size). if this bit is cleared, the user shal l rewrite correct values to the epbk and epsize fields in th e uecfgn register. ? ctrldir: control direction this bit is set after a setup packet to indicate that the following packet is an in packet. this bit is cleared after a setup packet to indicate that the following packet is an out packet. writing a zero or a one to this bit has no effect. ? rwall: read/write allowed this bit is set for in endpoints when the current bank is not full, i.e., the user can write further data into the fifo. this bit is set for out endpoints when the current bank is not empty, i.e., the user can read further data from the fifo. this bit is never set if stallrq is one or in case of error. this bit is cleared otherwise. this bit shall not be used for control endpoints. 31 30 29 28 27 26 25 24 - byct 23 22 21 20 19 18 17 16 byct - cfgok ctrldir rwall 15 14 13 12 11 10 9 8 currbk nbusybk - - dtseq 76543210 short packet stalledi/ crcerri overfi nakini nakouti rxstpi/ underfi rxouti txini
427 32059l?avr32?01/2012 at32uc3b ? currbk: current bank this bit is set for non-control endpoints, to indicate the current bank: this field may be updated one clock cycle after the rwall bit changes, so the user should not poll this field as an interrupt b it. ? nbusybk: number of busy banks this field is set to indicate the number of busy banks: for in endpoints, it indicates the number of banks filled by the user and ready for in transfer. when all banks are free, this triggers an epnint inte rrupt if nbusybke is one. for out endpoints, it indicates the number of banks filled by out transactions from the host. when all banks are busy, this triggers an epnint inte rrupt if nbusybke is one. when the fifocon bit is cleared (by writing a one to the fifoco nc bit) to validate a new bank, this field is updated two or three clock cycles later to calculate the address of the next bank. an epnint interrupt is triggered if: - for in endpoint, nbusybke is one and all the banks are free. - for out endpoint, nbusybke is one and all the banks are busy. ? dtseq: data toggle sequence this field is set to indicate the pid of the current bank: for in transfers, it indicates the data toggle sequence that will be used for the next packet to be sent. this is not relative to the current bank. for out transfers, this value indicates the last data toggle sequence received on the current bank. by default dtseq is 0b01, as if the last data toggle sequence was data1, so the next sent or expected data toggle sequence should be data0. ? shortpacket: short packet interrupt this bit is set for non-control out endpoints, when a short packet has been received. currbk current bank 00bank0 01bank1 1 0 bank2 if supported (see table 22-1 on page 352 ). 11reserved nbusybk number of busy banks 0 0 0 (all banks free) 011 102 1 1 3 if supported (see table 22-1 on page 352 ). dtseq data toggle sequence 00data0 01data1 1xreserved
428 32059l?avr32?01/2012 at32uc3b this bit is set for non-control in endpoints, a short packet is transmitted upon ending a dma transfer, thus signaling an end o f isochronous frame or a bulk or interrupt e nd of transfer, this only if the end of dma buffer output enable (dmaenden) bit and the automatic switch (autosw) bit are written to one. this triggers an epnint interru pt if shortpackete is one. this bit is cleared when the shortpacketc bit is wr itten to one. this will acknowledge the interrupt. ? stalledi: stalled interrupt this bit is set to signal that a stall handshake has been sent. to do that, the software has to set the stallrq bit (by writing a one to the stallrqs bit). this triggers an epnint interrupt if stallede is one. this bit is cleared when the stalledic bit is written to one. this will acknowledge the interrupt. ? crcerri: crc error interrupt this bit is set to signal that a crc error has been detected in an isochronous out endpoint. the out packet is stored in the bank as if no crc error had occurred. this triggers an epnint interrupt if crcerre is one. this bit is cleared when the crcerric bit is writ ten to one. this will acknowledge the interrupt. ? overfi: overflow interrupt this bit is set when an overflow error occurs. this triggers an epnint interrupt if overfe is one. for all endpoint types, an overflow can occur during out stage if the host attempts to write into a bank that is too small for the packet. the packet is acknowledged and the rxouti bit is set as if no overflow had occurred. the bank is filled with all the fi rst bytes of the packet that fit in. this bit is cleared when the overfic bit is written to one. this will acknowledge the interrupt. ? nakini: naked in interrupt this bit is set when a nak handshake has been sent in response to an in request from the host. this triggers an epnint interrupt if nakine is one. this bit is cleared when the nakinic bit is written to one. this will acknowledge the interrupt. ? nakouti: naked out interrupt this bit is set when a nak handshake has been sent in respons e to an out request from the host. this triggers an epnint interrupt if nakoute is one. this bit is cleared when the nakoutic bit is writ ten to one. this will acknowledge the interrupt. ? underfi: underflow interrupt this bit is set, for isochronous in/out endpoints, when an underflow error occurs. this triggers an epnint interrupt if underfe is one. an underflow can occur during in stage if the host attempts to read from an empty bank. a zero-length packet is then automatically s ent by the usbb. an underflow can also occur during out stage if the host sends a packet while the bank is already full. typically, the cpu is n ot fast enough. the packet is lost. shall be cleared by writing a one to the underfic bit. this will acknowledge the interrupt. this bit is inactive (cleared) for bulk and interrupt in/out endpoints and it means rxstpi for control endpoints. ? rxstpi: received setup interrupt this bit is set, for control endpoints, to signal that the curren t bank contains a new valid setup packet. this triggers an epn int interrupt if rxstpe is one. shall be cleared by writing a one to the rxstpic bit. this will acknowledge the interrupt and free the bank. this bit is inactive (cleared) for bulk and interrupt in/out endpoints and it means underfi for isochronous in/out endpoints. ? rxouti: received out data interrupt this bit is set, for control endpoints, when the current bank cont ains a bulk out packet (data or status stage). this triggers an epnint interrupt if rxoute is one. shall be cleared for control end points, by writing a one to th e rxoutic bit. this will acknowledge the interrupt and free the bank. this bit is set for isochronous, bulk and, interrupt out endpoint s, at the same time as fifocon when the current bank is full. this triggers an epnint interrupt if rxoute is one.
429 32059l?avr32?01/2012 at32uc3b shall be cleared for isochronous, bulk and, interrupt out endpoints, by writing a one to the rxoutic bit. this will acknowledge the interrupt, what has no effect on the endpoint fifo. the user then reads from the fifo and clear s the fifocon bit to free the bank. if the out endpoint is composed of multiple banks, this also switches to the next bank. the rxouti and fifoco n bits are set/cleared in accordance with the status of the next bank. rxouti shall always be cleared before clearing fifocon. this bit is inactive (cleared) for isochronous, bulk and interrupt in endpoints. ? txini: transmitted in data interrupt this bit is set for control endpoints, when the current bank is ready to accept a new in packet. this triggers an epnint interr upt if txine is one. this bit is cleared when the txinic bit is written to one. this will acknowledge the interrupt and send the packet. this bit is set for isochronous, bulk and interrupt in endpoint s, at the same time as fifocon when the current bank is free. this triggers an epnint interrupt if txine is one. this bit is cleared when the txinic bit is written to one. this will acknowledge the interrupt, what has no effect on the endpo int fifo. the user then writes into the fifo and clears t he fifocon bit to allow the usbb to send the data. if the in endpoint is composed of multiple banks, this also switches to the next bank. the txini and fifocon bits are set/cleared in accordance with the status of the next bank. txini shall always be cleared before clearing fifocon. this bit is inactive (cleared) for isochronous, bulk and interrupt out endpoints.
430 32059l?avr32?01/2012 at32uc3b 22.8.2.12 endpoint n status clear register register name: uestanclr, n in [0..6] access type: write-only offset: 0x0160 + (n * 0x04) read value: 0x00000000 writing a one to a bit in this register will clear the corresponding bit in uesta. writing a zero to a bit in this register has no effect. this bit always reads as zero. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 short packetc stalledic/ crcerric overfic nakinic nakoutic rxstpic/ underfic rxoutic txinic
431 32059l?avr32?01/2012 at32uc3b 22.8.2.13 endpoint n status set register register name: uestanset, n in [0..6] access type: write-only offset: 0x0190 + (n * 0x04) read value: 0x00000000 writing a one to a bit in this register will set the corresponding bit in uesta, what may be useful for test or debug purposes. writing a zero to a bit in this register has no effect. this bit always reads as zero. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - - nbusybks - - - 76543210 short packets stalledis/ crcerris overfis nakinis nakoutis rxstpis/ underfis rxoutis txinis
432 32059l?avr32?01/2012 at32uc3b 22.8.2.14 endpoint n control register register name: ueconn, n in [0..6] access type: read-only offset: 0x01c0 + (n * 0x04) reset value: 0x00000000 ? stallrq: stall request this bit is set when the stallrqs bit is written to one. this will request to send a stall handshake to the host. this bit is cleared when a new setup packet is received or when the stallrqc bit is written to zero. ? rstdt: reset data toggle this bit is set when the rstdts bit is written to one. this will clear the data toggle sequence , i.e., set to data0 the data to ggle sequence of the next sent (in endpoints) or received (out endpoints) packet. this bit is cleared instantaneously. the user does not have to wait for this bit to be cleared. ? epdishdma: endpoint interrup ts disable hdma request enable this bit is set when the epdishdmas is written to one. this will pause the on-going dma channel n transfer on any endpoint n interrupt (epnint), whatever the state of the endpoint n interrupt enable bit (epninte). the user then has to acknowledge or to disable the interrupt so urce (e.g. rxouti) or to clear the epdishdma bit (by writing a one to the epdishdmac bit) in order to complete the dma transfer. in ping-pong mode, if the interrupt is associated to a new sys tem-bank packet (e.g. bank1) and the current dma transfer is running on the previous packet (bank0), then the previous-packet dma transfer completes normally, but the new-packet dma transfer will not start (not requested). if the interrupt is not associated to a new system-bank packet (nakini, nakouti, etc.), then the request cancellation may occur at any time and may immediately pause the current dma transfer. this may be used for example to identify erroneous packets, to prevent them from being transferred into a buffer, to complete a dma transfer by software after reception of a short packet, etc. ? fifocon: fifo control for control endpoints: the fifocon and rwall bits are irrelevant. the software s hall therefore never use them on these endpoints. when read, their value is always 0. for in endpoints: this bit is set when the current bank is free, at the same time as txini. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - - - - stallrq rstdt - epdishdma 15 14 13 12 11 10 9 8 - fifocon killbk nbusybke - - -- 76543210 short packete stallede/ crcerre overfe nakine nakoute rxstpe/ underfe rxoute txine
433 32059l?avr32?01/2012 at32uc3b this bit is cleared (by writing a one to the fifoconc bit) to send the fifo data and to switch to the next bank. for out endpoints: this bit is set when the current bank is full, at the same time as rxouti. this bit is cleared (by writing a one to the fifoconc bit) to free the current bank and to switch to the next bank. ? killbk: kill in bank this bit is set when the killbks bit is writt en to one. this will kill the last written bank. this bit is cleared by hardware after the completion of the ?kill packet procedure?. the user shall wait for this bit to be clear ed before trying to process another in packet. caution: the bank is cleared wh en the ?kill packet? procedure is completed by the usbb core : if the bank is really killed, the nbusybk field is decremented. if the bank is not ?killed? but sent (in tr ansfer), the nbusybk field is decremented and the txini flag is set. this specific c ase can occur if at the same time an in token is coming and the user wants to kill this bank. note : if two banks are ready to be sent, the above specific case can not occur, because the first bank is sent (in transfer) w hile the last bank is killed. ? nbusybke: number of busy banks interrupt enable this bit is set when the nbusybkes bit is written to one. this will enable the number of busy banks interrupt (nbusybk). this bit is cleared when the nbusybkec bit is written to zero. this will disable the number of busy banks interrupt (nbusybk). ? shortpackete: short pa cket interrupt enable this bit is set when the shortpacketes bit is written to one. this will enable the short packet interrupt (shortpacket). this bit is cleared when the shortpacketec bit is writte n to one. this will disable the short packet interrupt (shortpacket). ? stallede: stalled interrupt enable this bit is set when the stalledes bit is written to one. this will enable the stalled interrupt (stalledi). this bit is cleared when the stallede c bit is written to one. this will disable the stalled interrupt (stalledi). ? crcerre: crc error interrupt enable this bit is set when the crcerres bit is written to one. this will enable the crc error interrupt (crcerri). this bit is cleared when the crcerrec bit is written to one. this will disable the crc error interrupt (crcerri). ? overfe: overflow interrupt enable this bit is set when the overfes bit is written to one. this will enable the overflow interrupt (overfi). this bit is cleared when the overfec bit is written to one. this will disable the overflow interrupt (overfi). ? nakine: naked in interrupt enable this bit is set when the nakines bit is written to one. this will enable the naked in interrupt (nakini). this bit is cleared when the nakinec bit is written to one. this will disable the naked in interrupt (nakini). ? nakoute: naked out interrupt enable this bit is set when the nakoutes bit is written to one. this will enable the naked out interrupt (nakouti). this bit is cleared when the nakoutec bit is written to one. this will disable the naked out interrupt (nakouti). ? rxstpe: received set up interrupt enable this bit is set when the rxstpes bit is written to one. this will enable the received setup interrupt (rxstpi). this bit is cleared when the rxstpec bit is written to one. this will disable the received setup interrupt (rxstpi). ? underfe: underflow interrupt enable this bit is set when the underfes bit is written to one. this will enable the underflow interrupt (underfi). this bit is cleared when the underfec bit is written to one. this will di sable the underflow interrupt (underfi). ? rxoute: received out data interrupt enable this bit is set when the rxoutes bit is written to one. this will enable the received out data interrupt (rxout). this bit is cleared when the rxoutec bit is written to one. this will disable the received out data interrupt (rxout). ? txine: transmitted in data interrupt enable this bit is set when the txines bit is written to one. this will enable the transmitted in data interrupt (txini). this bit is cleared when the txinec bit is written to one. this will disable the transmitted in data interrupt (txini).
434 32059l?avr32?01/2012 at32uc3b 22.8.2.15 endpoint n control clear register register name: ueconnclr, n in [0..6] access type: write-only offset: 0x0220 + (n * 0x04) read value: 0x00000000 writing a one to a bit in this register will clear the corresponding bit in ueconn. writing a zero to a bit in this register has no effect. this bit always reads as zero. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ----stallrqc-- epdishdmac 15 14 13 12 11 10 9 8 - fifoconc - nbusybkec - - -- 76543210 short packetec stalledec /crcerrec overfec nakinec nakoutec rxstpec/ underfec rxoutec txinec
435 32059l?avr32?01/2012 at32uc3b 22.8.2.16 endpoint n control set register register name: ueconnset, n in [0..6] access type: write-only offset: 0x01f0 + (n * 0x04) read value: 0x00000000 writing a one to a bit in this register will set the corresponding bit in ueconn. writing a zero to a bit in this register has no effect. this bit always reads as zero. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ----stallrqsrstdts- epdishdmas 15 14 13 12 11 10 9 8 - - killbks nbusybkes ---- 76543210 short packetes stalledes/ crcerres overfes nakines nakoutes rxstpes/ underfes rxoutes txines
436 32059l?avr32?01/2012 at32uc3b 22.8.2.17 device dma channel n next descriptor address register register name: uddmannextdesc , n in [1..6] access type: read/write offset: 0x0310 + (n - 1) * 0x10 reset value: 0x00000000 ? nxtdescaddr: next descriptor address this field contains the bits 31:4 of the 16-byte aligned address of the next channel descriptor to be processed. this field is written either or by descriptor loading. 31 30 29 28 27 26 25 24 nxtdescaddr[31:24] 23 22 21 20 19 18 17 16 nxtdescaddr[23:16] 15 14 13 12 11 10 9 8 nxtdescaddr[15:8] 76543210 nxtdescaddr[7:4] - - - -
437 32059l?avr32?01/2012 at32uc3b 22.8.2.18 device dma channel n hsb address register register name: uddmanaddr , n in [1..6] access type: read/write offset: 0x0314 + (n - 1) * 0x10 reset value: 0x00000000 ? hsbaddr: hsb address this field determines the hsb bus current address of a channel transfer. the address written to the hsb address bus is hsbaddr rounded down to the nearest word-aligned address, i.e., hsbaddr[1:0] is considered as 0b00 since only word accesses are performed. channel hsb start and end addresses may be aligned on any byte boundary. the user may write this field only when the channel enabl ed bit (chen) of the uddmanstatus register is cleared. this field is updated at the end of the address phase of the current access to the hsb bus. it is incremented of the hsb access byte-width. the hsb access width is 4 bytes, or less at packet start or end if the start or end address is not aligned on a word boundary. the packet start address is either the channel start address or the next channel address to be accessed in the channel buffer. the packet end address is either the channel end address or th e latest channel address accessed in the channel buffer. the channel start address is written or loaded from the descript or, whereas the channel end address is either determined by the end of buffer or the end of usb transfer if the buffer close input enable bit (buffcloseinen) is set. 31 30 29 28 27 26 25 24 hsbaddr[31:24] 23 22 21 20 19 18 17 16 hsbaddr[23:16] 15 14 13 12 11 10 9 8 hsbaddr[15:8] 76543210 hsbaddr[7:0]
438 32059l?avr32?01/2012 at32uc3b 22.8.2.19 device dma channel n control register register name: uddmancontrol , n in [1..6] access type: read/write offset: 0x0318 + (n - 1) * 0x10 reset value: 0x00000000 ? chbytelength: channel byte length this field determines the total number of bytes to be transferred for this buffer. the maximum channel transfer size 64kb is reached when this field is zero (default value). if the transfer size is unknown, the transfer end is controlled by the peripheral and this field should be written to zero. this field can be written or descriptor loading only after the uddmanstatus.chen bit has been cleared, otherwise this field is ignored. ? burstlocken: burst lock enable 1: the usb data burst is locked for maximum optimization of hsb busses bandwidth usage and maximization of fly-by duration. 0: the dma never locks the hsb access. ? descldirqen: descriptor loaded interrupt enable 1: the descriptor loaded interrupt is enabled.this interrupt is generated when a descriptor has been loaded from the system bus. 0: the descriptor loaded interrupt is disabled. ? eobuffirqen: end of buffer interrupt enable 1: the end of buffer interrupt is enabled.this interrupt is generated when the channel byte count reaches zero. 0: the end of buffer interrupt is disabled. ? eotirqen: end of usb transfer interrupt enable 1: the end of usb out data transfer interrupt is enabled. this interrupt is generated only if the buffcloseinen bit is set. 0: the end of usb out data transfer interrupt is disabled. ? dmaenden: end of dma buffer output enable writing a one to this bit will properly complete the usb transfer at the en d of the dma transfer. for in endpoint, it means that a short pack et (but not a zero length packet) will be sent to the usb line to properly closed th e usb transfer at the end of the dma transfer. for out endpoint, it means that all the banks will be pr operly released. (nbusybk=0) at the end of the dma transfer. 31 30 29 28 27 26 25 24 chbytelength[15:8] 23 22 21 20 19 18 17 16 chbytelength[7:0] 15 14 13 12 11 10 9 8 -------- 76543210 burstlocken descldirqen eobuffirqen eotirqen dmaenden buffclose inen ldnxtch descen chen
439 32059l?avr32?01/2012 at32uc3b ? buffcloseinen: buffe r close input enable for bulk and interrupt endpoint, writing a one to this bit will automatically close the current dma transfer at the end of the usb out data transfer (received short packet). for full-speed isochronous, it does not make sense, so buffcloseinen should be left to zero. writing a zero to this bit to disable this feature. ? ldnxtchdescen: load next channel descriptor enable 1: the channel controller loads the next descriptor after the end of the current transfer, i.e. when the uddmanstatus.chen bit is reset. 0: no channel register is loaded after the end of the channel transfer. if the chen bit is written to zero, the next descriptor is immediately loaded upon transfer request (endpoint is free for in endpoint, or endpoint is full for out endpoint). table 22-6. dma channel control command summary ? chen: channel enable writing this bit to zero will disabled the dma channel and no transfer will occur upon request. if the ldnxtchdescen bit is written to zero, the channel is frozen and the channel regist ers may then be read and/or written reliably as soon as both uddmanstatus.chen and chactive bits are zero. writing this bit to one will set the uddmanstatus.chen bit and enable dma channel data transfer. then any pending request will start the transfer. this may be used to start or resume any requested transfer. this bit is cleared when the channel sour ce bus is disabled at end of buffer. if the ldnxtchdescen bit has been cleared by descriptor loading, the user will have to write to one the corre sponding chen bit to start the described transfer, if needed. if a channel request is currently serviced when this bit is zero , the dma fifo buffer is drained until it is empty, then the uddmanstatus.chen bit is cleared. if the ldnxtchdescen bit is set or after this bit clearing, then the currently loaded descriptor is skipped (no data transfer occurs) and the next descriptor is immediately loaded. ldnxtchdes cen chen current bank 00stop now 0 1 run and stop at end of buffer 1 0 load next descriptor now 1 1 run and link at end of buffer
440 32059l?avr32?01/2012 at32uc3b 22.8.2.20 device dma channel n status register register name: uddmanstatus , n in [1..6] access type: read/write offset: 0x031c + (n - 1) * 0x10 reset value: 0x00000000 ? chbytecnt: channel byte count this field contains the current number of bytes still to be transferred for this buffer. this field is decremented at each dma access. this field is reliable (stable) only if the chen bit is zero. ? descldsta: descriptor loaded status this bit is set when a descriptor has been loaded from the hsb bus. this bit is cleared when read by the user. ? eochbuffsta: end of channel buffer status this bit is set when the channel byte count counts down to zero. this bit is automatically cleared when read by software. ? eotsta: end of usb transfer status this bit is set when the completion of the usb data transfer has closed the dma transfer. it is valid only if uddmancontrol.buffcloseinen is one. note that for out endpoint, if the uecfgn.autosw is set, any received zero- length-packet will be cancelled by the dma, and the eo tsta will be set whatever th e uddmancontrol.chen bit is. this bit is automatically cleared when read by software. ? chactive: channel active 0: the dma channel is no longer trying to source the packet data. 1: the dma channel is currently trying to source packet data, i. e. selected as the highest-priority requesting channel. when a packet transfer cannot be completed due to an eochbuffsta, this bit stays set during the next channel descriptor load (if any) and potentially until usb packet transfer completion, if allowed by the new descriptor. when programming a dma by descriptor (load next descriptor now), the chactive bit is set only once the dma is running (the endpoint is free for in transaction, the endpoint is full for out transaction). ? chen: channel enabled this bit is set (after one cycle latency) when the l. chen is written to one or when the descriptor is loaded. this bit is cleared when any transfer is ended either due to an elapsed byte count or a usb device initiated transfer end. 31 30 29 28 27 26 25 24 chbytecnt[15:8] 23 22 21 20 19 18 17 16 chbytecnt[7:0] 15 14 13 12 11 10 9 8 -------- 76543210 - descld sta eochbuff sta eotsta - - chactive chen
441 32059l?avr32?01/2012 at32uc3b 0: the dma channel no longer transfers data, and may load the next descriptor if the uddmancontrol.ldnxtchdescen bit is zero. 1: the dma channel is currently enabled and transfers data upon request. if a channel request is currently serviced when the uddmancont rol.chen bit is written to zero, the dma fifo buffer is drained until it is empty, then this status bit is cleared.
442 32059l?avr32?01/2012 at32uc3b 22.8.3 usb host registers 22.8.3.1 host general control register register name: uhcon access type: read/write offset: 0x0400 reset value: 0x00000000 ? resume: send usb resume writing a one to this bit will generate a usb resume on the usb bus. this bit is cleared when the usb resume has been sent or when a usb reset is requested. writing a zero to this bit has no effect. this bit should be written to one only when the st art of frame generation is enable. (sofe bit is one). ? reset: send usb reset writing a one to this bit will generate a usb reset on the usb bus. this bit is cleared when the usb reset has been sent. it may be useful to write a zero to this bit when a device disc onnection is detected (uhint.ddisci is one) whereas a usb reset is being sent. ? sofe: start of frame generation enable writing a one to this bit will generate sof on the usb bus in full speed mode and keep alive in low speed mode. writing a zero to this bit will disable the sof generation and to leave the usb bus in idle state. this bit is set when a usb reset is requested or an up stream resume interrupt is detected (uhint.rxrsmi). 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - - - - resume reset sofe 76543210 --------
443 32059l?avr32?01/2012 at32uc3b 22.8.3.2 host global interrupt register register name: uhint access type: read-only offset: 0x0404 reset value: 0x00000000 ? dmanint: dma channel n interrupt this bit is set when an interrupt is triggered by the dma channel n. this triggers a usb interrupt if the corresponding dmaninte is one (uhinte register). this bit is cleared when the uhdmanstatus interrupt source is cleared. ? pnint: pipe n interrupt this bit is set when an interrupt is triggered by the endpoint n (upstan). this triggers a usb interrupt if the corresponding p ipe interrupt enable bit is one (uhinte register). this bit is cleared when the interrupt source is served. ?hwupi: host wa ke-up interrupt this bit is set when the host controller is in the suspend mode (sofe is zero) and an upstream resume from the peripheral is detected. this bit is set when the host controller is in the suspend mode (sofe is zero) and a peripheral disconnection is detected. this bit is set when the host controller is in the idle state (usbsta.vbusrq is zero, no vbus is generated). this interrupt is generated even if the clock is frozen by the frzclk bit. ? hsofi: host start of frame interrupt this bit is set when a sof is issued by the host controller. this triggers a usb interrupt when hsofe is one. when using the host controller in low speed mode, this bit is also set when a keep-alive is sent. this bit is cleared when the hsofic bit is written to one. ? rxrsmi: upstream resume received interrupt this bit is set when an upstream resume has been received from the device. this bit is cleared when the rxrsmic is written to one. ? rsmedi: downstream resume sent interrupt this bit set when a downstream resume has been sent to the device. this bit is cleared when the rsmedic bit is written to one. ? rsti: usb reset sent interrupt this bit is set when a usb reset has been sent to the device. this bit is cleared when the rstic bit is written to one. 31 30 29 28 27 26 25 24 - dma6int dma5int dma4int dma3int dma2int dma1int - 23 22 21 20 19 18 17 16 ------- 15 14 13 12 11 10 9 8 - p6int p5int p4int p3int p2int p1int p0int 76543210 - hwupi hsofi rxrsmi rsmedi rsti ddisci dconni
444 32059l?avr32?01/2012 at32uc3b ? ddisci: device disconnection interrupt this bit is set when the device has been removed from the usb bus. this bit is cleared when the ddiscic bit is written to one. ? dconni: device co nnection interrupt this bit is set when a new device has been connected to the usb bus. this bit is cleared when the dconnic bit is written to one.
445 32059l?avr32?01/2012 at32uc3b 22.8.3.3 host global interrupt clear register register name: uhintclr access type: write-only offset: 0x0408 read value: 0x00000000 writing a one to a bit in this register will clear the corresponding bit in uhint. writing a zero to a bit in this register has no effect. this bit always reads as zero. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - hwupic hsofic rxrsmic rsme dic rstic ddiscic dconnic
446 32059l?avr32?01/2012 at32uc3b 22.8.3.4 host global interrupt set register register name: uhintset access type: write-only offset: 0x040c read value: 0x00000000 writing a one to a bit in this register will set the corresponding bit in uhint, what may be useful for test or debug purposes. writing a zero to a bit in this register has no effect. this bit always reads as zero. 31 30 29 28 27 26 25 24 - dma6ints dma5ints dma4ints d ma3ints dma2ints dma1ints - 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - hwupis hsofis rxrsmis rsmedis rstis ddiscis dconnis
447 32059l?avr32?01/2012 at32uc3b 22.8.3.5 host global interrupt enable register register name: uhinte access type: read-only offset: 0x0410 reset value: 0x00000000 ? dmaninte: dma channe l n interrupt enable this bit is set when the dmanintes bit is written to one. this will enable the dma channel n interrupt (dmanint). this bit is cleared when the dmanintec bit is written to one. this will disable the dma channel n interrupt (dmanint). ? pninte: pipe n interrupt enable this bit is set when the pnintes bit is written to one. this will enable the pipe n interrupt (pnint). this bit is cleared when the pnintec bit is written to one. this will disable the pipe n interrupt (pnint). ? hwupie: host wake-up interrupt enable this bit is set when the hwupies bit is written to one. this will enable the host wake-up interrupt (hwupi). this bit is cleared when the hwupiec bit is written to one. this will disable the host wake-up interrupt (hwupi). ? hsofie: host start of frame interrupt enable this bit is set when the hsofies bit is written to one. this will enable the host start of frame interrupt (hsofi). this bit is cleared when the hsofiec bit is written to one. this will disable the host start of frame interrupt (hsofi). ? rxrsmie: upstream resume received interrupt enable this bit is set when the rxrsmies bit is written to one. this will enable the upstream resume received interrupt (rxrsmi). this bit is cleared when the rxrsmiec bit is written to one . this will disable the downstream resume interrupt (rxrsmi). ? rsmedie: downstream resume sent interrupt enable this bit is set when the rsmedies bit is written to one. th is will enable the downstream resume interrupt (rsmedi). this bit is cleared when the rsmediec bit is written to one . this will disable the downstream resume interrupt (rsmedi). ? rstie: usb reset sent interrupt enable this bit is set when the rsties bit is written to one. this will enable the usb reset sent interrupt (rsti). this bit is cleared when the rstiec bit is written to one. this will disable the usb reset sent interrupt (rsti). ? ddiscie: device disconnection interrupt enable this bit is set when the ddiscies bit is written to one. th is will enable the device disconnection interrupt (ddisci). this bit is cleared when the ddisciec bit is written to one. this will disable the device disconnection interrupt (ddisci). ? dconnie: device connec tion interrupt enable this bit is set when the dconnies bit is written to one. this will enable the device connection interrupt (dconni). this bit is cleared when the dconniec bit is written to one. this will disable the device connection interrupt (dconni). 31 30 29 28 27 26 25 24 - dma6inte dma5inte dma4inte d ma3inte dma2inte dma1inte - 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - p6inte p5inte p4inte p3inte p2inte p1inte p0inte 76543210 - hwupie hsofie rxrsmie rsmedie rstie ddiscie dconnie
448 32059l?avr32?01/2012 at32uc3b 22.8.3.6 host global interrupt enable clear register register name: uhinteclr access type: write-only offset: 0x0414 read value: 0x00000000 writing a one to a bit in this register will clear the corresponding bit in uhinte. writing a zero to a bit in this register has no effect. this bit always reads as zero. 31 30 29 28 27 26 25 24 - dma6intec dma5intec dma4intec dma3intec dma2intec dma1intec - 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - p6intec p5intec p4intec p3in tec p2intec p1intec p0intec 76543210 - hwupiec hsofiec rxrsmiec rsmediec rstiec ddisciec dconniec
449 32059l?avr32?01/2012 at32uc3b 22.8.3.7 host global interrupt enable set register register name: uhinteset access type: write-only offset: 0x0418 read value: 0x00000000 writing a one to a bit in this register will set the corresponding bit in uhint. writing a zero to a bit in this register has no effect. this bit always reads as zero. 31 30 29 28 27 26 25 24 - dma6intes dma5intes dma4intes dma3intes dma2intes dma1intes - 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - p6intes p5intes p4intes p3in tes p2intes p1intes p0intes 76543210 - hwupies hsofies rxrsmies rsmedies rsties ddiscies dconnies
450 32059l?avr32?01/2012 at32uc3b 22.8.3.8 host frame number register register name: uhfnum access type: read/write offset: 0x0420 reset value: 0x00000000 ? flenhigh: frame length this field contains the 8 high-order bits of the 14-bits internal frame counter (frame counter at 12mhz, counter length is 1200 0 to ensure a sof generation every 1 ms). ? fnum: frame number this field contains the current sof number. this field can be written. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 flenhigh 15 14 13 12 11 10 9 8 - - fnum[10:5] 76543210 fnum[4:0] - - -
451 32059l?avr32?01/2012 at32uc3b 22.8.3.9 host address 1 register register name: uhaddr1 access type: read/write offset: 0x0424 reset value: 0x00000000 ? uhaddrp3: usb host address this field contains the address of the pipe3 of the usb device. this field is cleared when a usb reset is requested. ? uhaddrp2: usb host address this field contains the address of the pipe2 of the usb device. this field is cleared when a usb reset is requested. ? uhaddrp1: usb host address this field contains the address of the pipe1 of the usb device. this field is cleared when a usb reset is requested. ? uhaddrp0: usb host address this field contains the address of the pipe0 of the usb device. this field is cleared when a usb reset is requested. 31 30 29 28 27 26 25 24 - uhaddrp3 23 22 21 20 19 18 17 16 - uhaddrp2 15 14 13 12 11 10 9 8 - uhaddrp1 76543210 - uhaddrp0
452 32059l?avr32?01/2012 at32uc3b 22.8.3.10 host address 2 register register name: uhaddr2 access type: read/write offset: 0x0428 reset value: 0x00000000 ? uhaddrp6: usb host address this field contains the address of the pipe6 of the usb device. this field is cleared when a usb reset is requested. ? uhaddrp5: usb host address this field contains the address of the pipe5 of the usb device. this field is cleared when a usb reset is requested. ? uhaddrp4: usb host address this field contains the address of the pipe4 of the usb device. this field is cleared when a usb reset is requested. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - uhaddrp6 15 14 13 12 11 10 9 8 - uhaddrp5 76543210 - uhaddrp4
453 32059l?avr32?01/2012 at32uc3b 22.8.3.11 pipe enable/reset register register name: uprst access type: read/write offset: 0x0041c reset value: 0x00000000 ? prstn: pipe n reset writing a one to this bit will reset the pipe n fifo. this resets the endpoint n registers (upcfgn, upstan, upco nn) but not the endpoint configuration (alloc, pbk, psize, ptoken, ptype, pepnum, intfrq). all the endpoint mechanism (fifo counter, reception, transmission, etc.) is reset apart from the data toggle management. the endpoint configuration remains active and the endpoint is still enabled. writing a zero to this bit will complete the reset operation and allow to start using the fifo. ? penn: pipe n enable writing a one to this bit will enable the pipe n. writing a zero to this bit will disable the pipe n, what forces the pipe n state to inactive and resets the pipe n registers (u pcfgn, upstan, upconn) but not the pipe c onfiguration (all oc, pbk, psize). 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - prst6 prst5 prst4 prst3 prst2 prst1 prst0 15 14 13 12 11 10 9 8 -------- 76543210 - pen6 pen5 pen4 pen3 pen2 pen1 pen0
454 32059l?avr32?01/2012 at32uc3b 22.8.3.12 pipe n configuration register register name: upcfgn, n in [0..6] access type: read/write offset: 0x0500 + (n * 0x04) reset value: 0x00000000 ? intfrq: pipe interrupt request frequency this field contains the maximum value in millisecond of the polling period for an interrupt pipe. this value has no effect for a non-interrupt pipe. this field is cleared upon sending a usb reset. ? pepnum: pipe endpoint number this field contains the number of the endpoint ta rgeted by the pipe. this value is from 0 to 15. this field is cleared upon sending a usb reset. ? ptype: pipe type this field contains the pipe type. this field is cleared upon sending a usb reset. ? autosw: automatic switch this bit is cleared upon sending a usb reset. 1: the automatic bank switching is enabled. 0: the automatic bank switching is disabled. 31 30 29 28 27 26 25 24 intfrq 23 22 21 20 19 18 17 16 ---- pepnum 15 14 13 12 11 10 9 8 - - ptype - autosw ptoken 76543210 - psize pbk alloc - ptype pipe type 0 0 control 0 1 isochronous 10bulk 1 1 interrupt
455 32059l?avr32?01/2012 at32uc3b ? ptoken: pipe token this field contains the endpoint token. ? psize: pipe size this field contains the size of each pipe bank. this field is cleared upon sending a usb reset. ? pbk: pipe banks this field contains the number of banks for the pipe. for control endpoints, a single-bank pipe (0b00) should be selected. this field is cleared upon sending a usb reset. ? alloc: pipe memory allocate writing a one to this bit will allocate the pipe memory. writing a zero to this bit will free the pipe memory. this bit is cleared when a usb reset is requested. refer to the dpram management chapter for more details. ptoken endpoint direction 00 setup 01 in 10 out 11 reserved psize endpoint size 0 0 0 8 bytes 0 0 1 16 bytes 0 1 0 32 bytes 0 1 1 64 bytes 1 0 0 128 bytes 1 0 1 256 bytes 1 1 0 512 bytes 1 1 1 1024 bytes pbk endpoint banks 0 0 1 (single-bank pipe) 0 1 2 (double-bank pipe) 1 0 3 (triple-bank pipe) if supported (see table 22-1 on page 352 ). 11reserved
456 32059l?avr32?01/2012 at32uc3b 22.8.3.13 pipe n status register register name: upstan, n in [0..6] access type: read-only offset: 0x0530 + (n * 0x04) reset value: 0x00000000 ? pbyct: pipe byte count this field contains the byte count of the fifo. for out pipe, incremented after each byte written by the user into the pipe and decremented after each byte sent to the peripheral. for in pipe, incremented after each byte received from the peri pheral and decremented after each byte read by the user from the pipe. this field may be updated 1 clock cycle after the rwall bit changes , so the user should not poll this field as an interrupt bit . ? cfgok: configuration ok status this bit is set/cleared when the upcfgn.alloc bit is set. this bit is set if the pipe n number of banks (upcfgn.pbk) a nd size (upcfgn.psize) are corr ect compared to the maximal allowed number of banks and size for this pipe and to the maximal fifo size (i.e., the dpram size). if this bit is cleared, the user sh ould rewrite correct values ot the pbk a nd psize field in the upcfgn register. ? rwall: read/write allowed for out pipe, this bit is set when the current bank is not full, i.e., the software can write further data into the fifo. for in pipe, this bit is set when the current bank is not empty, i.e., the software can read further data from the fifo. this bit is cleared otherwise. this bit is also cleared when the rxstall or the perr bit is one. ? currbk: current bank for non-control pipe, this field indicates the number of the current bank. 31 30 29 28 27 26 25 24 - pbyct[10:4] 23 22 21 20 19 18 17 16 pbyct[3:0] - cfgok - rwall 15 14 13 12 11 10 9 8 currbk nbusybk - - dtseq 76543210 short packeti rxstalldi/ crcerri overfi nakedi perri txstpi/ underfi txouti rxini currbk current bank 00bank0
457 32059l?avr32?01/2012 at32uc3b this field may be updated 1 clock cycle after the rwall bit changes , so the user shall not poll this field as an interrupt bit. ? nbusybk: number of busy banks this field indicates the number of busy bank. for out pipe, this field indicates the number of busy bank(s), filled by the user, ready for out transfer. when all banks are busy, this triggers an pnint in terrupt if upconn.nbusybke is one. for in pipe, this field indicates the number of busy bank(s) fill ed by in transaction from the device. when all banks are free, this triggers an pnint interrupt if upconn.nbusybke is one. ? dtseq: data toggle sequence this field indicates the data pid of the current bank. for out pipe, this field indicates the data toggle of the next packet that will be sent. for in pipe, this field indicates the data toggle of the received packet stored in the current bank. ? shortpacketi: shor t packet interrupt this bit is set when a short packet is received by the host controller (packet length inferior to the psize programmed field). this bit is cleared when the shortpacketic bit is written to one. ? rxstalldi: received stalled interrupt this bit is set, for all endpoints but isochronous, when a stall handshake has been received on the current bank of the pipe. the pipe is automatically frozen. this trigger s an interrupt if the rxstalle bit is one. this bit is cleared when the rxstalldic bit is written to one. ? crcerri: crc error interrupt this bit is set, for isochronous endpoint, when a crc error occurs on the current bank of the pipe. this triggers an interrupt if the txstpe bit is one. this bit is cleared when the crcerric bit is written to one. ? overfi: overflow interrupt this bit is set when the current pipe has received more data than the maximum length of the current pipe. an interrupt is triggered if the overfie bit is one. this bit is cleared when the overfic bit is written to one. ? nakedi: naked interrupt this bit is set when a n ak has been received on th e current bank of the pipe. this trigger s an interrupt if the nakede bit is o ne. 01bank1 1 0 bank2 if supported (see table 22-1 on page 352 ). 11reserved nbusybk number of busy bank 0 0 all banks are free. 0 1 1 busy bank 1 0 2 busy banks if supported (see table 22-1 on page 352 ). 1 1 reserved dtseq data toggle sequence 00data0 01data1 1 0 reserved 1 1 reserved currbk current bank
458 32059l?avr32?01/2012 at32uc3b this bit is cleared when the nakedic bit written to one. ? perri: pipe error interrupt this bit is set when an error occurs on the current bank of the pipe. this triggers an interrupt if the perre bit is set. refer s to the uperrn register to determine the source of the error. this bit is cleared when the error source bit is cleared. ? txstpi: transmitte d setup interrupt this bit is set, for control endpoints, when the current setup bank is free and can be filled. this triggers an interrupt if th e txstpe bit is one. this bit is cleared when the txstpic bit is written to one. ? underfi: underflow interrupt this bit is set, for isochronous and interrupt in/out pipe, when an error flow occurs. this triggers an interrupt if the underf ie bit is one. this bit is set, for isochronous or interrupt out pipe, when a transaction underflow occurs in the current pipe. (the pipe can? t send the out data packet in time because the current bank is not ready). a zero-length-packet (zlp) will be sent instead of. this bit is set, for isochronous or interrupt in pipe, when a transaction flow error occurs in the current pipe. i.e, the curre nt bank of the pipe is not free whereas a new in usb packet is received. this packet is not stored in the bank. for interrupt pipe, the overflowed packet is acked to respect the usb standard. this bit is cleared when the underfiec bit is written to one. ? txouti: transmitted out data interrupt this bit is set when the current out bank is free and can be filled. this triggers an interrupt if the txoute bit is one. this bit is cleared when the txoutic bit is written to one. ? rxini: received in data interrupt this bit is set when a new usb message is stored in the current bank of the pipe. this triggers an interrupt if the rxine bit i s one. this bit is cleared when the rxinic bit is written to one.
459 32059l?avr32?01/2012 at32uc3b 22.8.3.14 pipe n status clear register register name: upstanclr, n in [0..6] access type: write-only offset: 0x0560 + (n * 0x04) read value: 0x00000000 writing a one to a bit in this register will clear the corresponding bit in upstan. writing a zero to a bit in this register has no effect. this bit always reads as zero. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 short packetic rxstalldi c/ crcerric overfic nakedic - txstpic/ underfic txoutic rxinic
460 32059l?avr32?01/2012 at32uc3b 22.8.3.15 pipe n status set register register name: upstanset, n in [0..6] access type: write-only offset: 0x0590 + (n * 0x04) read value: 0x00000000 writing a one to a bit in this register will set the corresponding bit in upstan, what may be useful for test or debug purposes . writing a zero to a bit in this register has no effect. this bit always reads as zero. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - - nbusybks - - - - 76543210 short packetis rxstalldis / crcerris overfis nakedis perris txstpis/ underfis txoutis rxinis
461 32059l?avr32?01/2012 at32uc3b 22.8.3.16 pipe n control register register name: upconn, n in [0..6] access type: read-only offset: 0x05c0 + (n * 0x04) reset value: 0x00000000 ? rstdt: reset data toggle this bit is set when the rstdts bit is written to one. this will reset the data toggle to its initial value for the current pip e. this bit is cleared when proceed. ? pfreeze: pipe freeze this bit is set when the pfreezes bit is written to one or wh en the pipe is not configured or when a stall handshake has been received on this pipe or when an error occurs on the pipe (perr is one) or when (inrq+1) in requests have been processed or when after a pipe reset (uprst.prstn rising) or a pipe enable (uprst.pen rising). this will freeze the pipe requests generation. this bit is cleared when the pfreezec bit is written to one. this will enable the pipe request generation. ? pdishdma: pipe interrupts disable hdma request enable see the ueconn.epdishdma bit description. ? fifocon: fifo control for out and setup pipe: this bit is set when the current bank is free, at the same time than txouti or txstpi. this bit is cleared when the fifoconc bit is written to one. this will send the fifo data and switch the bank. for in pipe: this bit is set when a new in message is stored in the current bank, at the same time than rxini. this bit is cleared when the fifoconc bit is written to one. this will free the current bank and switch to the next bank. ? nbusybke: number of busy banks interrupt enable this bit is set when the nbusybkes bit is written to one.this will enable the tr ansmitted in data interrupt (nbusybke). this bit is cleared when the nbusybkec bi t is written to one. this will disable t he transmitted in data interrupt (nbusybke). ? shortpacketie: short packet interrupt enable this bit is set when the shortpacketes bit is written to one. this will enable the transmitted in data it (shortpacketie). this bit is cleared when the shortpacketec bit is written to one. this will disable the transmitted in data it (shortpackete). 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - - - - - rstdt pfreeze pdishdma 15 14 13 12 11 10 9 8 - fifocon - nbusybke - - - - 76543210 short packetie rxstallde /crcerre overfie nakede perre txstpe/ underfie txoute rxine
462 32059l?avr32?01/2012 at32uc3b ? rxstallde: received stalled interrupt enable this bit is set when the rxstalldes bit is written to one. th is will enable the transmitted in data interrupt (rxstallde). this bit is cleared when the rxstalldec bit is written to one. this will disable the transmitted in data interrupt (rxstallde). ? crcerre: crc error interrupt enable this bit is set when the crcerres bit is written to one. th is will enable the transmitted in data interrupt (crcerre). this bit is cleared when the crcerrec bit is written to one. th is will disable the transmitted in data interrupt (crcerre). ? overfie: overflow interrupt enable this bit is set when the overfies bit is written to one. th is will enable the transmitted in data interrupt (overfie). this bit is cleared when the overfiec bit is written to one. this will disable the transmitted in data interrupt (overfie). ? nakede: naked interrupt enable this bit is set when the nakedes bit is written to one. th is will enable the transmitted in data interrupt (nakede). this bit is cleared when the nakedec bit is written to o ne. this will disable the transmi tted in data in terrupt (nakede). ? perre: pipe error interrupt enable this bit is set when the perres bit is written to one. th is will enable the transmitted in data interrupt (perre). this bit is cleared when the perrec bit is written to one. this will disable the transmitted in data interrupt (perre). ? txstpe: transmitted set up interrupt enable this bit is set when the txstpes bit is written to one. this wi ll enable the transmi tted in data inte rrupt (txstpe). this bit is cleared when the txstpec bit is written to one. this will disable the transmitted in data interrupt (txstpe). ? underfie: underflo w interrupt enable this bit is set when the underfies bit is written to one. th is will enable the transmitted in data interrupt (underfie). this bit is cleared when the underfiec bit is written to one. th is will disable the transmitted in data interrupt (underfie). ? txoute: transmitted out data interrupt enable this bit is set when the txoutes bit is written to one. this will enable the transmitted in data interrupt (txoute). this bit is cleared when the txoutec bit is written to one. th is will disable the transmitted in data interrupt (txoute). ? rxine: received in data interrupt enable this bit is set when the rxines bit is written to one. this will enable the transmitted in data interrupt (rxine). this bit is cleared when the rxinec bit is written to one. this will disable the transmitted in data interrupt (rxine).
463 32059l?avr32?01/2012 at32uc3b 22.8.3.17 pipe n control clear register register name: upconnclr, n in [0..6] access type: write-only offset: 0x0620 + (n * 0x04) read value: 0x00000000 writing a one to a bit in this register will clear the corresponding bit in upconn. writing a zero to a bit in this register has no effect. this bit always reads as zero. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - - - - - - pfreezec pdishdmac 15 14 13 12 11 10 9 8 - fifoconc - nbusybkec ---- 76543210 short packetiec rxstalldec /crcerrec overfiec nakedec perrec txstpec/ underfiec txoutec rxinec
464 32059l?avr32?01/2012 at32uc3b 22.8.3.18 pipe n control set register register name: upconnset, n in [0..6] access type: write-only offset: 0x05f0 + (n * 0x04) read value: 0x00000000 writing a one to a bit in this register will set the corresponding bit in upconn. writing a zero to a bit in this register has no effect. this bit always reads as zero. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - - - - - rstdts pfreezes pdishdmas 15 14 13 12 11 10 9 8 --- nbusybkes ---- 76543210 short packeties rxstalldes / crcerres overfies nakedes perres txstpes/ underfies txoutes rxines
465 32059l?avr32?01/2012 at32uc3b 22.8.3.19 pipe n in request register register name: upinrqn, n in [0..6] access type: read/write offset: 0x0650 + (n * 0x04) reset value: 0x00000000 ? inmode: in request mode writing a one to this bit will allow the usbb to perform infinite in requests when the pipe is not frozen. writing a zero to this bit will perform a pre-defined nu mber of in requests. this number is the inrq field. ? inrq: in request number before freeze this field contains the number of in transactions before the usbb freezes the pipe. the usbb will perform (inrq+1) in requests before to freeze the pipe. this counter is automatica lly decreased by 1 each time a in request has been successfully performed. this register has no effect when the inmode bit is one (i nfinite in requests generation till the pipe is not frozen). 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------inmode 76543210 inrq
466 32059l?avr32?01/2012 at32uc3b 22.8.3.20 pipe n error register register name: uperrn, n in [0..6] access type: read/write offset: 0x0680 + (n * 0x04) reset value: 0x00000000 ? counter: error counter this field is incremented each time an error occu rs (crc16, timeout, pid, datapid or datatgl). this field is cleared when receiving a good usb packet without any error. when this field reaches 3 (i.e., 3 consecutive errors), this pipe is automatically frozen (upconn.pfreeze is set). writing 0b00 to this field will clear the counter. ? crc16: crc16 error this bit is set when a crc16 error has been detected. writing a zero to this bit will clear the bit. writing a one to this bit has no effect. ? timeout: time-out error this bit is set when a time-out error has been detected. writing a zero to this bit will clear the bit. writing a one to this bit has no effect. ?pid: pid error this bit is set when a pid error has been detected. writing a zero to this bit will clear the bit. writing a one to this bit has no effect. ? datapid: data pid error this bit is set when a data pid error has been detected. writing a zero to this bit will clear the bit. writing a one to this bit has no effect. ? datatgl: data toggle error this bit is set when a data toggle error has been detected. writing a zero to this bit will clear the bit. writing a one to this bit has no effect. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - counter crc16 timeout pid datapid datatgl
467 32059l?avr32?01/2012 at32uc3b 22.8.3.21 host dma channel n next descriptor address register register name: uhdmannextdesc , n in [1..6] access type: read/write offset: 0x0710 + (n - 1) * 0x10 reset value: 0x00000000 same as section 22.8.2.17 . 31 30 29 28 27 26 25 24 nxtdescaddr[31:24] 23 22 21 20 19 18 17 16 nxtdescaddr[23:16] 15 14 13 12 11 10 9 8 nxtdescaddr[15:8] 76543210 nxtdescaddr[7:4] - - - -
468 32059l?avr32?01/2012 at32uc3b 22.8.3.22 host dma channel n hsb address register register name: uhdmanaddr , n in [1..6] access type: read/write offset: 0x0714 + (n - 1) * 0x10 reset value: 0x00000000 same as section 22.8.2.18 . 31 30 29 28 27 26 25 24 hsbaddr[31:24] 23 22 21 20 19 18 17 16 hsbaddr[23:16] 15 14 13 12 11 10 9 8 hsbaddr[15:8] 76543210 hsbaddr[7:0]
469 32059l?avr32?01/2012 at32uc3b 22.8.3.23 usb host dma channel n control register register name: uhdmancontrol , n in [1..6] access type: read/write offset: 0x0718 + (n - 1) * 0x10 reset value: 0x00000000 same as section 22.8.2.19 . (just replace the in endpoint term by out endpoint, and vice-versa) 31 30 29 28 27 26 25 24 chbytelength[15:8] 23 22 21 20 19 18 17 16 chbytelength[7:0] 15 14 13 12 11 10 9 8 -------- 76543210 burstloc ken descld irqen eobuff irqen eotirqen dmaenden buffclose inen ldnxtchd escen chen
470 32059l?avr32?01/2012 at32uc3b 22.8.3.24 usb host dma channel n status register register name: uhdmanstatus , n in [1..6] access type: read/write offset: 0x071c + (n - 1) * 0x10 reset value: 0x00000000 same as section 22.8.2.20 . 31 30 29 28 27 26 25 24 chbytecnt[15:8] 23 22 21 20 19 18 17 16 chbytecnt[7:0] 15 14 13 12 11 10 9 8 -------- 76543210 - descld sta eochbuffs ta eotsta - - chactive chen
471 32059l?avr32?01/2012 at32uc3b 22.8.4 usb pipe/endpoint n fifo data register (usbfifondata) the application has access to the physical dp ram reserved for the endpoint/pipe through a 64kb virtual address space. the application ca n access anywhere in t he virtual 64kb segment (linearly or fixedly) as the dpram fifo address increment is fully handled by hardware. byte, half-word and word access are supported. data should be access in a big-endian way. for instance, if the app lication wants to write into the endp oint/pipe3, it can access anywhere in the usbfifo3data hsb segment address. i.e : an access to the 0x30000 offset, is strictly equivalent to an access to the 0x3fffc offset. note that the virtual address space size (64kb) has nothing to do with the endpoint/pipe size. disabling the usbb (by writing a zero to the usbe bit) does not reset the dpram.
472 32059l?avr32?01/2012 at32uc3b 23. timer/counter (tc) rev: 2.2.2.3 23.1 features ? three 16-bit timer counter channels ? a wide range of functions including: ? frequency measurement ? event counting ? interval measurement ? pulse generation ? delay timing ? pulse width modulation ? up/down capabilities ? each channel is user-configurable and contains: ? three external clock inputs ? five internal clock inputs ? two multi-purpose input/output signals ? internal interrupt signal ? two global registers that act on all three tc channels 23.2 overview the timer counter (tc) includes three identical 16-bit timer counter channels. each channel can be independently programmed to perform a wide range of functions including frequency measurement, event counting, interval measurement, pulse generation, delay timing, and pulse width modulation. each channel has three external clock inputs, fi ve internal clock inputs, and two multi-purpose input/output signals which can be configured by t he user. each channel drives an internal inter- rupt signal which can be programmed to generate processor interrupts. the tc block has two global registers which act upon all three tc channels. the block control register (bcr) allows the th ree channels to be star ted simultaneously with the same instruction. the block mode register (bmr) defines the ex ternal clock inputs for each channel, allowing them to be chained.
473 32059l?avr32?01/2012 at32uc3b 23.3 block diagram figure 23-1. tc block diagram 23.4 i/o lines description 23.5 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 23.5.1 i/o lines the pins used for interfacing the compliant exte rnal devices may be multiplexed with i/o lines. the user must first program the i/o controller to assign the tc pins to their peripheral functions. i/o co n t r o l l e r tc2xc2s int0 int1 int2 tioa0 tioa1 tioa2 tiob0 tiob1 tiob2 xc2 tclk0 tclk1 tclk2 tclk0 tclk1 tclk2 tclk0 tclk1 tclk2 tioa1 tioa2 tioa0 tioa2 tioa1 interrupt controller clk0 clk1 clk2 a0 b0 a1 b1 a2 b2 timer count er tiob tioa tiob sync timer_clock1 tioa sync sync tioa tiob timer_clock2 timer_clock3 timer_clock4 timer_clock5 xc1 xc0 xc0 xc2 xc1 xc0 xc1 xc2 timer/counter channel 2 timer/counter channel 1 timer/counter channel 0 tc1xc1s tc0xc0s tioa0 table 23-1. i/o lines description pin name description type clk0-clk2 external clock input input a0-a2 i/o line a input/output b0-b2 i/o line b input/output
474 32059l?avr32?01/2012 at32uc3b 23.5.2 power management if the cpu enters a sleep mode that disables cl ocks used by the tc, the tc will stop functioning and resume operation after the system wakes up from sleep mode. 23.5.3 clocks the clock for the tc bus interface (clk_tc) is generated by the power manager. this clock is enabled at reset, and can be disabled in the power manager. it is recommended to disable the tc before disabling the clock, to avoid freezing the tc in an undefined state. 23.5.4 interrupts the tc interrupt request line is connected to t he interrupt controller. using the tc interrupt requires the interrupt controller to be programmed first. 23.5.5 debug operation the timer counter clocks are frozen du ring debug operation, unle ss the ocd system keeps peripherals running in debug operation. 23.6 functional description 23.6.1 tc description the three channels of the timer counter are independent and identical in operation. the regis- ters for channel programming are listed in figure 23-3 on page 489 . 23.6.1.1 channel i/o signals as described in figure 23-1 on page 473 , each channel has the following i/o signals. 23.6.1.2 16-bit counter each channel is organized around a 16-bit counter. the value of the counter is incremented at each positive edge of the selected clock. when the counter has reached the value 0xffff and passes to 0x0000, an overflow occurs and the co unter overflow status bit in the channel n sta- tus register (srn.covfs) is set. the current value of the counter is accessible in real time by reading the channel n counter value register (cvn). the counter can be reset by a trigger. in this case, the counter value passes to 0x0000 on the next valid edge of the selected clock. table 23-2. channel i/o signals description block/channel sign al name description channel signal xc0, xc1, xc2 external clock inputs tioa capture mode: timer counter input waveform mode: timer counter output tiob capture mode: timer counter input waveform mode: timer counter input/output int interrupt signal output sync synchronization input signal
475 32059l?avr32?01/2012 at32uc3b 23.6.1.3 clock selection at block level, input clock signals of each channel can either be connected to the external inputs tclk0, tclk1 or tclk2, or be connected to the configurable i/o signals a0, a1 or a2 for chaining by writing to the bmr register. see figure 23-2 on page 475 . each channel can independently select an internal or external clock source for its counter: ? internal clock signals: timer_clock1, timer_clock2, timer_clock3, timer_clock4, timer_clock5. see the module configuration chapter for details about the connection of these clock sources. ? external clock signals: xc0, xc1 or xc2. see the module configuration chapter for details about the connection of these clock sources. this selection is made by the clock sele ction field in the ch annel n mode register (cmrn.tcclks). the selected clock can be inverted with the clock invert bit in cmrn (cmrn.clki). this allows counting on the opposite edges of the clock. the burst function allows the clock to be valida ted when an external signal is high. the burst signal selection field in the cmrn regi ster (cmrn.burst) defines this signal. note: in all cases, if an external clock is used, the duration of each of its levels must be longer than the clk_tc period. the external clock frequency must be at least 2.5 times lower than the clk_tc. figure 23-2. clock selection 23.6.1.4 clock control the clock of each counter can be controlled in two different ways: it can be enabled/disabled and started/stopped. see figure 23-3 on page 476 . timer_clock5 xc2 tcclks clki burst 1 selected clock xc1 xc0 timer_clock4 timer_clock3 timer_clock2 timer_clock1
476 32059l?avr32?01/2012 at32uc3b ? the clock can be enabled or disabled by the user by writing to the counter clock enable/disable command bits in the channe l n clock control regist er (ccrn.clken and ccrn.clkdis). in capture mode it can be disabled by an rb load event if the counter clock disable with rb loading bit in cmrn is written to one (cmrn.ldbdis). in waveform mode, it can be disabled by an rc compare event if the counter clock disable with rc compare bit in cmrn is written to one (cmr n.cpcdis). when disabled, the start or the stop actions have no effect: only a clken command in ccrn can re-enable the clock. when the clock is enabled, the clock enabling stat us bit is set in srn (srn.clksta). ? the clock can also be started or stopped: a trigger (software, synchro, external or compare) always starts the clock. in capture mode the clo ck can be stopped by an rb load event if the counter clock stopped with rb loading bit in cmrn is written to one (cmrn.ldbstop). in waveform mode it can be stopped by an rc compare event if the counter clock stopped with rc compare bit in cmrn is written to one (cmrn.cpcstop). the start and the stop commands have effect only if the clock is enabled. figure 23-3. clock control 23.6.1.5 tc operating modes each channel can independently operate in two different modes: ? capture mode provides measurement on signals. ? waveform mode provides wave generation. the tc operating mode selection is done by writ ing to the wave bit in the ccrn register (ccrn.wave). in capture mode, tioa and tiob are configured as inputs. in waveform mode, tioa is always configured to be an output and tiob is an output if it is not selected to be the external trigger. qs r s r q clksta clken clkdis stop event disable counter clock selected clock trigger event
477 32059l?avr32?01/2012 at32uc3b 23.6.1.6 trigger a trigger resets the counter and starts the counter clock. three types of triggers are common to both modes, and a fourth external trigger is available to each mode. the following triggers are common to both modes: ? software trigger: each channel has a software trigger, available by writing a one to the software trigger command bit in ccrn (ccrn.swtrg). ? sync: each channel has a synchronization signal sync. when asserted, this signal has the same effect as a software trigger. the sync signals of all channels are asserted simultaneously by writing a one to the synchro command bit in the bcr register (bcr.sync). ? compare rc trigger: rc is implemented in each channel and can provide a trigger when the counter value matches the rc value if the rc compare trigger enable bit in cmrn (cmrn.cpctrg) is written to one. the channel can also be configured to have an external trigger. in capture mode, the external trigger signal can be selected between tioa and tiob. in waveform mode, an external event can be programmed to be one of the following si gnals: tiob, xc0, xc1, or xc2. this external event can then be programmed to perform a trigge r by writing a one to the external event trig- ger enable bit in cmrn (cmrn.enetrg). if an external trigger is used, the duration of t he pulses must be longer than the clk_tc period in order to be detected. regardless of the trigger used, it will be taken into account at the following active edge of the selected clock. this means that the counter value can be read differently from zero just after a trigger, especially when a low frequency signal is selected as the clock. 23.6.2 capture operating mode this mode is entered by writin g a zero to the cmrn.wave bit. capture mode allows the tc channel to perform measurements such as pulse timing, fre- quency, period, duty cycle and phase on tioa and tiob sig nals which are considered as inputs. figure 23-4 on page 479 shows the configuration of the tc channel when programmed in cap- ture mode. 23.6.2.1 capture registers a and b registers a and b (ra and rb) are used as capture registers. this means that they can be loaded with the counter value when a progr ammable event occurs on the signal tioa. the ra loading selection field in cmrn (cmrn. ldra) defines the tioa edge for the loading of the ra register, and the rb loading selection fi eld in cmrn (cmrn.ldrb) defines the tioa edge for the loading of the rb register. ra is loaded only if it has not been loaded since the last trigger or if rb has been loaded since the last loading of ra. rb is loaded only if ra has been loaded sinc e the last trigger or t he last loading of rb. loading ra or rb before the read of the last value loaded sets the load overrun status bit in srn (srn.lovrs). in this case, the old value is overwritten.
478 32059l?avr32?01/2012 at32uc3b 23.6.2.2 trigger conditions in addition to the sync signal, the software trigge r and the rc compare trigger, an external trig- ger can be defined. the tioa or tiob external trigger selecti on bit in cmrn (cmrn.abetrg) selects tioa or tiob input signal as an external trigger. the external trigger edge selection bit in cmrn (cmrn.etredg) defines the edge (rising, falling or both) detected to generate an external trig- ger. if cmrn.etrgedg is zero (non e), the external trigger is disabled.
479 32059l?avr32?01/2012 at32uc3b figure 23-4. capture mode timer_clock1 xc 0 xc 1 xc 2 tcclks clki qs r s r q clksta clken clkdis burst tiob capture register a compare rc = 16-bit counter abetrg swtrg etrgedg cpctrg imr trig ldrbs ldras etrgs sr lovrs covfs sync 1 mtiob tioa mtioa ldra ldbstop if ra is not loaded or rb is loaded if ra is loaded ldbdis cpcs int ed g e det ect or ldrb clk ovf reset timer/counter channel edge detector edge detector capture register b register c timer_clock2 timer_clock3 timer_clock4 timer_clock5
480 32059l?avr32?01/2012 at32uc3b 23.6.3 waveform operating mode waveform operating mode is entered by writing a one to the cmrn.wave bit. in waveform operating mode the tc channel generates one or two pwm signals with the same frequency and independently programmable duty cy cles, or generates different types of one- shot or repetitive pulses. in this mode, tioa is configured as an output and tiob is defined as an output if it is not used as an external event. figure 23-5 on page 481 shows the configuration of the tc channel when programmed in waveform operating mode. 23.6.3.1 wavefo rm selection depending on the waveform se lection field in cmrn (cmrn. wavsel), the behavior of cvn varies. with any selection, ra, rb and rc can all be used as compare registers. ra compare is used to control th e tioa output, rb compare is us ed to control the tiob output (if correctly configured) and rc compare is used to control tioa and/or tiob outputs.
481 32059l?avr32?01/2012 at32uc3b figure 23-5. waveform mode tcclks clki qs r s r q clksta clken clkdis cpcdis burst tiob register a compare rc = cpcstop 16-bit counter eevt eev t e d g sync swtrg en etr g wavsel imr tr i g acpc acpa aeevt aswtrg bcpc bcpb beevt bswtrg tioa mtioa tiob mtiob cpas covfs etrgs sr cpcs cpbs clk ovf reset output controller o utput contr oller int 1 ed g e det ect o r timer/counter channel timer_clock1 xc 0 xc 1 xc 2 wavsel register b register c compare rb = compare ra = timer_clock2 timer_clock3 timer_clock4 timer_clock5
482 32059l?avr32?01/2012 at32uc3b 23.6.3.2 wavsel = 0 when cmrn.wavsel is zero, t he value of cvn is increment ed from 0 to 0xffff. once 0xffff has been reached, the value of cvn is re set. incrementation of cvn starts again and the cycle continues. see figure 23-6 on page 482 . an external event trigger or a software trigger c an reset the value of cvn. it is important to note that the trigger may occur at any time. see figure 23-7 on page 483 . rc compare cannot be programmed to generate a trigger in this configuration. at the same time, rc compare can stop the counter clock (c mrn.cpcstop = 1) and/or disable the counter clock (cmrn.cpcdis = 1). figure 23-6. wavsel= 0 without trigger time counter value rc rb ra tiob tioa counter cleared by compare match with 0xffff 0xffff waveform examples
483 32059l?avr32?01/2012 at32uc3b figure 23-7. wavsel= 0 with trigger 23.6.3.3 wavsel = 2 when cmrn.wavsel is two, the value of cvn is incremented from zero to the value of rc, then automatically reset on a rc compare. once the value of cvn has been reset, it is then incremented and so on. see figure 23-8 on page 484 . it is important to note that cvn can be reset at any time by an external event or a software trig- ger if both are programmed correctly. see figure 23-9 on page 484 . in addition, rc compare can stop the counter clock (cmrn.cpcstop) and/or disable the counter clock (cmrn.cpcdis = 1). time counter value rc rb ra tiob tioa counter cleared by compare match with 0xffff 0xffff waveform examples counter cleared by trigger
484 32059l?avr32?01/2012 at32uc3b figure 23-8. wavsel = 2 without trigger figure 23-9. wavsel = 2 with trigger 23.6.3.4 wavsel = 1 when cmrn.wavsel is one, the value of cvn is incremented from 0 to 0xffff. once 0xffff is reached, the value of cvn is decremented to 0, then re-incremented to 0xffff and so on. see figure 23-10 on page 485 . time counter value rc rb ra tiob tioa counter cleared by compare match with rc 0xffff waveform examples time counter value r c r b r a tiob tioa counter cleared by compare match with rc 0xffff waveform examples counter cleared by trigger
485 32059l?avr32?01/2012 at32uc3b a trigger such as an external event or a software trigger can modify cvn at any time. if a trigger occurs while cvn is incrementing, cvn then decrements. if a trigger is received while cvn is decrementing, cvn then increments. see figure 23-11 on page 485 . rc compare cannot be programmed to gene rate a trigger in th is configuration. at the same time, rc compare can stop the counter clock (cmrn.cpcstop = 1) and/or dis- able the counter clock (cmrn.cpcdis = 1). figure 23-10. wavsel = 1 without trigger figure 23-11. wavsel = 1 with trigger time counter value rc rb ra tiob tioa counter decremented by compare match with 0xffff 0xffff waveform examples time counter value tiob tioa counter decremented by compare match with 0xffff 0xffff waveform examples counter decremented by trigger rc rb ra counter incremented by trigger
486 32059l?avr32?01/2012 at32uc3b 23.6.3.5 wavsel = 3 when cmrn.wavsel is three, the value of cvn is incremented from ze ro to rc. once rc is reached, the value of cvn is decremented to zero, then re-incremented to rc and so on. see figure 23-12 on page 486 . a trigger such as an external event or a software trigger can modify cvn at any time. if a trigger occurs while cvn is incrementing, cvn then decrements. if a trigger is received while cvn is decrementing, cvn then increments. see figure 23-13 on page 487 . rc compare can stop the counter clock (cmrn.cp cstop = 1) and/or disable the counter clock (cmrn.cpcdis = 1). figure 23-12. wavsel = 3 without trigger time counter value rc rb ra tiob tioa counter cleared by compare match with rc 0xffff waveform examples
487 32059l?avr32?01/2012 at32uc3b figure 23-13. wavsel = 3 with trigger 23.6.3.6 external event/trigger conditions an external event can be programmed to be detected on one of the clock sources (xc0, xc1, xc2) or tiob. the external event selected can then be used as a trigger. the external event selection field in cmrn (cmrn.eevt) selects the external trigger. the external event edge selection field in cmrn (cmrn.eevtedg) defines the trigger edge for each of the possible external tr iggers (rising, falling or both ). if cmrn.eevtedg is written to zero, no external event is defined. if tiob is defined as an ex ternal event signal (cmrn.eevt = 0), tiob is no longer used as an output and the compare register b is not used to generate waveforms and subsequently no irqs. in this case the tc channel ca n only generate a waveform on tioa. when an external event is defined, it can be used as a trigger by writing a one to the cmrn.enetrg bit. as in capture mode, the sync signal and the softw are trigger are also available as triggers. rc compare can also be used as a trigger depending on the cmrn.wavsel field. 23.6.3.7 output controller the output controller defines the output level changes on tioa and tiob following an event. tiob control is used only if tiob is defin ed as output (not as an external event). the following events control tioa and tiob: ? software trigger ? external event ? rc compare ra compare controls tioa and rb compare c ontrols tiob. each of these events can be pro- grammed to set, clear or toggle the output as defined in the following fields in cmrn: ? rc compare effect on tiob (cmrn.bcpc) time counter value tiob tioa counter decremented by compare match with rc 0xffff waveform examples rc rb ra counter decremented by trigger counter incremented by trigger
488 32059l?avr32?01/2012 at32uc3b ? rb compare effect on tiob (cmrn.bcpb) ? rc compare effect on tioa (cmrn.acpc) ? ra compare effect on tioa (cmrn.acpa)
489 32059l?avr32?01/2012 at32uc3b 23.7 user interface table 23-3. tc register memory map offset register register name access reset 0x00 channel 0 control register ccr0 write-only 0x00000000 0x04 channel 0 mode register cmr0 read/write 0x00000000 0x10 channel 0 counter value cv0 read-only 0x00000000 0x14 channel 0 register a ra0 read/write (1) 0x00000000 0x18 channel 0 register b rb0 read/write (1) 0x00000000 0x1c channel 0 register c rc0 read/write 0x00000000 0x20 channel 0 status register sr0 read-only 0x00000000 0x24 interrupt enable register ier0 write-only 0x00000000 0x28 channel 0 interrupt disable register idr0 write-only 0x00000000 0x2c channel 0 interrupt mask register imr0 read-only 0x00000000 0x40 channel 1 control register ccr1 write-only 0x00000000 0x44 channel 1 mode register cmr1 read/write 0x00000000 0x50 channel 1 counter value cv1 read-only 0x00000000 0x54 channel 1 register a ra1 read/write (1) 0x00000000 0x58 channel 1 register b rb1 read/write (1) 0x00000000 0x5c channel 1 register c rc1 read/write 0x00000000 0x60 channel 1 status register sr1 read-only 0x00000000 0x64 channel 1 interrupt enable register ier1 write-only 0x00000000 0x68 channel 1 interrupt disable register idr1 write-only 0x00000000 0x6c channel 1 interrupt mask register imr1 read-only 0x00000000 0x80 channel 2 control register ccr2 write-only 0x00000000 0x84 channel 2 mode register cmr2 read/write 0x00000000 0x90 channel 2 counter value cv2 read-only 0x00000000 0x94 channel 2 register a ra2 read/write (1) 0x00000000 0x98 channel 2 register b rb2 read/write (1) 0x00000000 0x9c channel 2 register c rc2 read/write 0x00000000 0xa0 channel 2 status register sr2 read-only 0x00000000 0xa4 channel 2 interrupt enable register ier2 write-only 0x00000000 0xa8 channel 2 interrupt disable register idr2 write-only 0x00000000 0xac channel 2 interrupt mask register imr2 read-only 0x00000000 0xc0 block control register bcr write-only 0x00000000 0xc4 block mode register bmr read/write 0x00000000 0xf8 features register features read-only - (2) 0xfc version register version read-only - (2)
490 32059l?avr32?01/2012 at32uc3b notes: 1. read-only if cmrn.wave is zero. 2. the reset values are device specific. please refer to the module configuration section at the end of this chapter.
491 32059l?avr32?01/2012 at32uc3b 23.7.1 channel control register name: ccr access type: write-only offset: 0x00 + n * 0x40 reset value: 0x00000000 ? swtrg: software trigger command 1: writing a one to this bit will perform a software trigger: the counter is reset and the clock is started. 0: writing a zero to this bit has no effect. ? clkdis: counter cl ock disable command 1: writing a one to this bit will disable the clock. 0: writing a zero to this bit has no effect. ? clken: counter clock enable command 1: writing a one to this bit will enable the clock if clkdis is not one. 0: writing a zero to this bit has no effect. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - - - swtrg clkdis clken
492 32059l?avr32?01/2012 at32uc3b 23.7.2 channel mode register: capture mode name: cmr access type: read/write offset: 0x04 + n * 0x40 reset value: 0x00000000 ? ldrb: rb loading selection ? ldra: ra loading selection ?wave 1: capture mode is disabled (waveform mode is enabled). 0: capture mode is enabled. ? cpctrg: rc compare trigger enable 1: rc compare resets the counter and starts the counter clock. 0: rc compare has no effect on the counter and its clock. ? abetrg: tioa or tiob external trigger selection 1: tioa is used as an external trigger. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - - - - ldrb ldra 15 14 13 12 11 10 9 8 wave cpctrg - - - abetrg etrgedg 76543210 ldbdis ldbstop burst clki tcclks ldrb edge 0 none 1 rising edge of tioa 2 falling edge of tioa 3 each edge of tioa ldra edge 0 none 1 rising edge of tioa 2 falling edge of tioa 3 each edge of tioa
493 32059l?avr32?01/2012 at32uc3b 0: tiob is used as an external trigger. ? etrgedg: external trigger edge selection ? ldbdis: counter clock disable with rb loading 1: counter clock is disabled when rb loading occurs. 0: counter clock is not disabled when rb loading occurs. ? ldbstop: counter clock stopped with rb loading 1: counter clock is stopped when rb loading occurs. 0: counter clock is not stopped when rb loading occurs. ? burst: burst signal selection ? clki: clock invert 1: the counter is incremented on falling edge of the clock. 0: the counter is incremented on rising edge of the clock. ? tcclks: clock selection etrgedg edge 0 none 1 rising edge 2 falling edge 3 each edge burst burst signal selection 0 the clock is not gated by an external signal 1 xc0 is anded with the selected clock 2 xc1 is anded with the selected clock 3 xc2 is anded with the selected clock tcclks clock selected 0timer_clock1 1timer_clock2 2timer_clock3 3timer_clock4 4timer_clock5 5xc0 6xc1 7xc2
494 32059l?avr32?01/2012 at32uc3b 23.7.3 channel mode register: waveform mode name: cmr access type: read/write offset: 0x04 + n * 0x40 reset value: 0x00000000 ? bswtrg: software trigger effect on tiob ? beevt: external even t effect on tiob 31 30 29 28 27 26 25 24 bswtrg beevt bcpc bcpb 23 22 21 20 19 18 17 16 aswtrg aeevt acpc acpa 15 14 13 12 11 10 9 8 wave wavsel enetrg eevt eevtedg 76543210 cpcdis cpcstop burst clki tcclks bswtrg effect 0 none 1set 2clear 3 toggle beevt effect 0 none 1set 2clear 3 toggle
495 32059l?avr32?01/2012 at32uc3b ? bcpc: rc compare effect on tiob ? bcpb: rb compare effect on tiob ? aswtrg: software trigger effect on tioa ? aeevt: external even t effect on tioa ? acpc: rc compare effect on tioa bcpc effect 0 none 1set 2clear 3 toggle bcpb effect 0 none 1set 2clear 3 toggle aswtrg effect 0 none 1set 2clear 3 toggle aeevt effect 0 none 1set 2clear 3 toggle acpc effect 0 none 1set 2clear 3 toggle
496 32059l?avr32?01/2012 at32uc3b ? acpa: ra compare effect on tioa ?wave 1: waveform mode is enabled. 0: waveform mode is disabled (capture mode is enabled). ? wavsel: waveform selection ? enetrg: external event trigger enable 1: the external event resets the counter and starts the counter clock. 0: the external event has no effect on the counter and its clock. in this case, the selected external event only controls the t ioa output. ? eevt: external event selection note: 1. if tiob is chosen as the external event signal, it is conf igured as an input and no longer generates waveforms and subse- quently no irqs . ? eevtedg: external ev ent edge selection ? cpcdis: counter clock disable with rc compare 1: counter clock is disabled when counter reaches rc. 0: counter clock is not disabled when counter reaches rc. acpa effect 0 none 1set 2clear 3 toggle wavsel effect 0 up mode without automatic trigger on rc compare 1 updown mode without automatic trigger on rc compare 2 up mode with automatic trigger on rc compare 3 updown mode with automatic trigger on rc compare eevt signal selected as ex ternal event tiob direction 0 tiob input (1) 1 xc0 output 2 xc1 output 3 xc2 output eevtedg edge 0none 1 rising edge 2 falling edge 3 each edge
497 32059l?avr32?01/2012 at32uc3b ? cpcstop: counter clock stopped with rc compare 1: counter clock is stopped when counter reaches rc. 0: counter clock is not stopped when counter reaches rc. ? burst: burst signal selection ? clki: clock invert 1: counter is incremented on falling edge of the clock. 0: counter is incremented on rising edge of the clock. ? tcclks: clock selection burst burst signal selection 0 the clock is not gated by an external signal. 1 xc0 is anded with the selected clock. 2 xc1 is anded with the selected clock. 3 xc2 is anded with the selected clock. tcclks clock selected 0timer_clock1 1timer_clock2 2timer_clock3 3timer_clock4 4timer_clock5 5xc0 6xc1 7xc2
498 32059l?avr32?01/2012 at32uc3b 23.7.4 channel counter value register name: cv access type: read-only offset: 0x10 + n * 0x40 reset value: 0x00000000 ? cv: counter value cv contains the counter value in real time. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 cv[15:8] 76543210 cv[7:0]
499 32059l?avr32?01/2012 at32uc3b 23.7.5 channel register a name: ra access type: read-only if cmrn.wave = 0, read/write if cmrn.wave = 1 offset: 0x14 + n * 0x40 reset value: 0x00000000 ? ra: register a ra contains the register a value in real time. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ra[15:8] 76543210 ra[7:0]
500 32059l?avr32?01/2012 at32uc3b 23.7.6 channel register b name: rb access type: read-only if cmrn.wave = 0, read/write if cmrn.wave = 1 offset: 0x18 + n * 0x40 reset value: 0x00000000 ? rb: register b rb contains the register b value in real time. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 rb[15:8] 76543210 rb[7:0]
501 32059l?avr32?01/2012 at32uc3b 23.7.7 channel register c name: rc access type: read/write offset: 0x1c + n * 0x40 reset value: 0x00000000 ? rc: register c rc contains the register c value in real time. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 rc[15:8] 76543210 rc[7:0]
502 32059l?avr32?01/2012 at32uc3b 23.7.8 channel status register name: sr access type: read-only offset: 0x20 + n * 0x40 reset value: 0x00000000 note: reading the status register will also clear th e interrupt bit for the co rresponding interrupts. ? mtiob: tiob mirror 1: tiob is high. if cmrn.wave is zero, this means that tiob pin is high. if cmrn.wave is one, th is means that tiob is driven high. 0: tiob is low. if cmrn.wave is zero, this means that tiob pin is low. if cmrn.wave is one, this means that tiob is driven low. ? mtioa: tioa mirror 1: tioa is high. if cmrn.wave is zero, this means that tioa pin is high. if cmrn.wave is one, th is means that tioa is driven high. 0: tioa is low. if cmrn.wave is zero, this means that tioa pin is low. if cmrn.wave is one, this means that tioa is driven low. ? clksta: clock enabling status 1: this bit is set when the clock is enabled. 0: this bit is cleared when the clock is disabled. ? etrgs: external trigger status 1: this bit is set when an external trigger has occurred. 0: this bit is cleared when the sr register is read. ? ldrbs: rb loading status 1: this bit is set when an rb load has occurred and cmrn.wave is zero. 0: this bit is cleared when the sr register is read. ? ldras: ra loading status 1: this bit is set when an ra load has occurred and cmrn.wave is zero. 0: this bit is cleared when the sr register is read. ? cpcs: rc compare status 1: this bit is set when an rc compare has occurred. 0: this bit is cleared when the sr register is read. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -----mtiobmtioaclksta 15 14 13 12 11 10 9 8 -------- 76543210 etrgs ldrbs ldras cpcs cpbs cpas lovrs covfs
503 32059l?avr32?01/2012 at32uc3b ? cpbs: rb compare status 1: this bit is set when an rb compare has occurred and cmrn.wave is one. 0: this bit is cleared when the sr register is read. ? cpas: ra compare status 1: this bit is set when an ra compare has occurred and cmrn.wave is one. 0: this bit is cleared when the sr register is read. ? lovrs: load overrun status 1: this bit is set when ra or rb have been loaded at least twice without any read of the corresponding register and cmrn.wave is zero. 0: this bit is cleared when the sr register is read. ? covfs: counter overflow status 1: this bit is set when a counter overflow has occurred. 0: this bit is cleared when the sr register is read.
504 32059l?avr32?01/2012 at32uc3b 23.7.9 channel interrupt enable register name: ier access type: write-only offset: 0x24 + n * 0x40 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 etrgs ldrbs ldras cpcs cpbs cpas lovrs covfs
505 32059l?avr32?01/2012 at32uc3b 23.7.10 channel interrupt disable register name: idr access type: write-only offset: 0x28 + n * 0x40 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 etrgs ldrbs ldras cpcs cpbs cpas lovrs covfs
506 32059l?avr32?01/2012 at32uc3b 23.7.11 channel interrupt mask register name: imr access type: read-only offset: 0x2c + n * 0x40 reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. a bit in this register is cleared when the corresponding bit in idr is written to one. a bit in this register is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 etrgs ldrbs ldras cpcs cpbs cpas lovrs covfs
507 32059l?avr32?01/2012 at32uc3b 23.7.12 block control register name: bcr access type: write-only offset: 0xc0 reset value: 0x00000000 ? sync: synchro command 1: writing a one to this bit asserts the sync signal which generates a software trigger simultaneously for each of the channels . 0: writing a zero to this bit has no effect. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------sync
508 32059l?avr32?01/2012 at32uc3b 23.7.13 block mode register name: bmr access type: read/write offset: 0xc4 reset value: 0x00000000 ? tc2xc2s: external clock signal 2 selection ? tc1xc1s: external clock signal 1 selection 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - tc2xc2s tc1xc1s tc0xc0s tc2xc2s signal connected to xc2 0tclk2 1none 2tioa0 3tioa1 tc1xc1s signal connected to xc1 0tclk1 1none 2tioa0 3tioa2
509 32059l?avr32?01/2012 at32uc3b ? tc0xc0s: external clock signal 0 selection tc0xc0s signal connected to xc0 0tclk0 1none 2tioa1 3tioa2
510 32059l?avr32?01/2012 at32uc3b 23.7.14 features register name: features access type: read-only offset: 0xf8 reset value: - ? brpbhsb: bridge type is pb to hsb 1: bridge type is pb to hsb. 0: bridge type is not pb to hsb. ? updnimpl: up/down is implemented 1: up/down counter capability is implemented. 0: up/down counter capability is not implemented. ? ctrsize: counter size this field indicates the size of the counter in bits. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ------- 15 14 13 12 11 10 9 8 - - - - - - brpbhsb updnimpl 76543210 ctrsize
511 32059l?avr32?01/2012 at32uc3b 23.7.15 version register name: version access type: read-only offset: 0xfc reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
512 32059l?avr32?01/2012 at32uc3b 23.8 module configuration the specific configurat ion for each tc instance is listed in the following tables.the module bus clocks listed here are connected to the system bus clocks according to the table in the power manager section. 23.8.1 clock connections each timer/counter channel can independently select an internal or external clock source for its counter: table 23-4. module clock name module name clock name tc0 clk_tc0 table 23-5. timer/counter clock connections source name connection internal timer_clock1 32 khz oscillator timer_clock2 pba clock / 2 timer_clock3 pba clock / 8 timer_clock4 pba clock / 32 timer_clock5 pba clock / 128
513 32059l?avr32?01/2012 at32uc3b 24. pulse width modulation controller (pwm) rev: 1.3.0.1 24.1 features ? 7 channels ? one 20-bit counter per channel ? common clock generator providin g thirteen different clocks ? a modulo n counter providing eleven clocks ? two independent linear dividers working on modulo n counter outputs ? independent channels ? independent enable disable command for each channel ? independent clock selection for each channel ? independent period and duty cycle for each channel ? double buffering of period or duty cycle for each channel ? programmable selection of the output waveform polarity for each channel ? programmable center or left aligned output waveform for each channel 24.2 description the pwm macrocell controls several cha nnels independently. each channel controls one square output waveform. characte ristics of the output waveform such as period, duty-cycle and polarity are configurable through the user interface. each channel selects and uses one of the clocks provided by the clock generator. the cloc k generator provides several clocks resulting from the division of the pwm macrocell master clock. all pwm macrocell accesses are made through registers mapped on the peripheral bus. channels can be synchronized, to generate non overlapped waveforms. all channels integrate a double buffering system in order to prevent an unexpected output waveform while modifying the period or the duty-cycle.
514 32059l?avr32?01/2012 at32uc3b 24.3 block diagram figure 24-1. pulse width modulation controller block diagram 24.4 i/o lines description each channel outputs one waveform on one external i/o line. pwm controller per ipheral bus pwmx pwmx channel dut y cy cl e count er pwm0 channel i/o controller interrupt controller power manager clk_pwm clockgenerator pb interface clock selector update dut y cy cl e count er clock se l ect o r period pwm0 interrupt generator period update table 24-1. i/o line description name description type pwmx pwm waveform output for channel x output
515 32059l?avr32?01/2012 at32uc3b 24.5 product dependencies 24.5.1 i/o lines the pins used for interfacing the pwm may be mu ltiplexed with i/o controller lines. the pro- grammer must first program the i/o controller to assign the desired pwm pins to their peripheral function. if i/o lines of the pwm are not used by the application, they ca n be used for other pur- poses by the i/o controller. not all pwm outputs may be enabled. if an application requires only four channels, then only four i/o lines will be as signed to pwm outputs. 24.5.2 debug operation the pwm clock is running during debug operation. 24.5.3 power manager the pwm clock is generated by the power m anager. before using the pwm, the user must ensure that the pwm clock is enabled in the power manager. however, if the application does not require pwm operations, the pwm clock can be stopped when not needed and be restarted later. in this case, th e pwm will resume its operat ions where it left off. in the pwm description, clk_pw m is the clock of the peripheral bus to which the pwm is connected. 24.5.4 interrupts the pwm interrupt line is connected to the interrupt controller. using the pwm interrupt requires the interrupt controller to be programmed first.
516 32059l?avr32?01/2012 at32uc3b 24.6 functional description the pwm macrocell is primarily composed of a clock generator module and 7 channels. ? clocked by the system clock, clk_pwm, the clock generator module provides 13 clocks. ? each channel can independently choose one of the clock generator outputs. ? each channel generates an output waveform with attributes that can be defined independently for each channel thro ugh the user interface registers. 24.6.1 pwm clock generator figure 24-2. functional view of the clock generator block diagram caution: before using the pwm macrocell, the programmer must ensure that the pwm clock in the power manager is enabled. the pwm macrocell master clock, clk_pwm, is divided in the clock generator module to pro- vide different clocks available for all channels. ea ch channel can independently select one of the modulo n counter clk_pwm clk_pwm/2 divider a clk a diva mr clk_pwm prea divider b clk b divb mr preb clk_pwm/4 clk_pwm/8 clk_pwm/32 clk_pwm/16 clk_pwm/64 clk_pwm/128 clk_pwm/256 clk_pwm/512 clk_pwm/1024
517 32059l?avr32?01/2012 at32uc3b divided clocks. the clock generator is divided in three blocks: ? a modulo n counter which provides 11 clocks: f clk_pwm , f clk_pwm /2, f clk_pwm /4, f clk_pwm /8, f clk_pwm /16, f clk_pwm /32, f clk_pwm /64, f clk_pwm /128, f clk_pwm /256, f clk_pwm /512, f clk_pwm /1024 ? two linear dividers (1, 1/2, 1/3, ... 1/255) that provide two separate clocks: clka and clkb each linear divider can independently divide one of the clocks of the modulo n counter. the selection of the clock to be divided is made ac cording to the pr ea (preb) field of the mode reg- ister (mr). the resulting clock cl ka (clkb) is the clock selected divided by diva (divb) field value in the mode register (mr). after a reset of the pwm controller, diva (divb) and prea (preb) in the mode register are cleared. this implies that after reset clka (clkb) are turned off. at reset, all clocks provided by the modulo n coun ter are turned off except clock ?clk?. this situa- tion is also true when the pwm master clock is turned off through the power manager . 24.6.2 pwm channel 24.6.2.1 block diagram figure 24-3. functional view of the channel block diagram each of the 7 channels is composed of three blocks: ? a clock selector which selects one of the clocks provided by the clock generator described in section 24.6.1 . ? an internal counter clocked by the output of the clock selector. this internal counter is incremented or decremented according to the channel configuration and comparators events. the size of the internal counter is 20 bits. ? a comparator used to generate events according to the internal counter value. it also computes the pwmx output waveform according to the configuration. 24.6.2.2 waveform properties the different properties of output waveforms are: ? the internal clock selection . the internal channel counter is clocked by one of the clocks provided by the clock generator described in the previous section. this channel parameter is defined in the cpre field of the cmrx register. this field is reset at 0. comparator pwmx output waveform internal counter clock selector inputs from clock generator inputs from peripheral bus channel
518 32059l?avr32?01/2012 at32uc3b ? the waveform period . this channel parameter is defined in the cprd field of the cprdx register. - if the waveform is left aligned, then the output waveform period depends on the counter source clock and can be calculated: by using the master clock (clk_pwm) divided by an x given prescaler value (with x being 1, 2, 4, 8, 16, 32, 64, 128, 25 6, 512, or 1024), the resulting period formula will be: by using a master clock divided by one of bo th diva or divb divider, the formula becomes, respectively: or if the waveform is center aligned then the output waveform period depends on the counter source clock and can be calculated: by using the master clock (clk_pwm) divided by an x given prescaler value (with x being 1, 2, 4, 8, 16, 32 , 64, 128, 256, 512, or 1024). the resulting pe riod formula will be: by using a master clock divided by one of bo th diva or divb divider, the formula becomes, respectively: or ? the waveform duty cycle . this channel parameter is defined in the cdty field of the cdtyx register. if the waveform is left aligned then: if the waveform is center aligned, then: ? the waveform polarity. at the beginning of the period, the signal can be at high or low level. this property is defined in the cpol field of the cmrx register. by default the signal starts by a low level. ? the waveform alignment . the output waveform can be left or center aligned. center aligned waveforms can be used to generate non overlapped waveforms. this property is defined in the calg field of the cmrx register. the default mode is left aligned. xcprd () clk_pwm ------------------------------- crpd diva () clk_pwm ------------------------------------------ crpd divab () clk_pwm ---------------------------------------------- 2 x cprd () clk_pwm ---------------------------------------- - 2 cprd diva () clk_pwm --------------------------------------------------- - 2 cprd divb () clk_pwm --------------------------------------------------- - duty cycle period 1 fchannel_x_clock cdty ? ? () period ------------------------------------------------------------------------------------------------------- - = duty cycle period 2 ? () 1 fchannel_x_clock cdty ? ? ()) period 2 ? () ---------------------------------------------------------------------------------------------------------------------- - =
519 32059l?avr32?01/2012 at32uc3b figure 24-4. non overlapped center aligned waveforms note: 1. see figure 24-5 on page 520 for a detailed description of center aligned waveforms. when center aligned, the internal channel count er increases up to cprd and.decreases down to 0. this ends the period. when left aligned, the internal channel counter increases up to cprd and is reset. this ends the period. thus, for the same cprd value, the period for a ce nter aligned channel is twice the period for a left aligned channel. waveforms are fixed at 0 when: ? cdty = cprd and cpol = 0 ? cdty = 0 and cpol = 1 waveforms are fixed at 1 (once the channel is enabled) when: ? cdty = 0 and cpol = 0 ? cdty = cprd and cpol = 1 the waveform polarity must be set before enab ling the channel. this immediately affects the channel output level. changes on channel polarity are not taken into account while the channel is enabled. pwm0 pwm1 per i o d no overlap
520 32059l?avr32?01/2012 at32uc3b figure 24-5. waveform properties clk_pwm pe r i o d per i o d chidx (sr) chidx (ena) ccntx cprd(cprdx) cdty(cdtyx) output waveform pwmx cpol(cmrx) = 0 output waveform pwmx cpol(cmrx) = 1 chidx (isr) ccntx cprd(cprdx) cdty(cdtyx) output waveform pwmx cpol(cmrx) = 0 output waveform pwmx cpol(cmrx) = 1 chidx (isr) center aligned calg (cmrx) = 1 left aligned calg (cmrx) = 0
521 32059l?avr32?01/2012 at32uc3b 24.6.3 pwm controller operations 24.6.3.1 initialization before enabling the output channel, this chann el must have been configured by the software application: ? configuration of the clock genera tor if diva and divb are required ? selection of the clock for each chann el (cpre field in the cmrx register) ? configuration of the waveform alignment for eac h channel (calg field in the cmrx register) ? configuration of the period for each channel (cprd in the cprdx register). writing in cprdx register is possible while the channel is disabled. after validation of the channel, the user must use cupdx register to update cprdx as explained below. ? configuration of the duty cycle for each chan nel (cdty in the cdtyx register). writing in cdtyx register is possible while the channel is disabled. after validation of the channel, the user must use cupdx register to update cdtyx as explained below. ? configuration of the output waveform polarity for each channel (cpol in the cmrx register) ? enable interrupts (writing chidx in the ier register) ? enable the pwm channel (writing chidx in the ena register) it is possible to synchronize different channels by enabling them at the same time by means of writing simultaneously several chi dx bits in the ena register. in such a situation, all channels may have the same clock selector configuration and the same period specified. 24.6.3.2 source clock selection criteria the large number of source clocks can make selection difficult. the relationship between the value in the period register (cprdx) and the du ty cycle register (cdtyx) can help the user in choosing. the event number written in the pe riod register gives the pwm accuracy. the duty cycle quantum cannot be lower than 1/cprdx value. the higher the value of cprdx, the greater the pwm accuracy. for example, if the user sets 15 (in decimal) in cprdx, the user is able to set a value between 1 up to 14 in cdtyx register. the resulting duty cycle quantum cannot be lower than 1/15 of the pwm period. 24.6.3.3 changing the duty cycle or the period it is possible to modulate the output waveform duty cycle or period. to prevent unexpected output wa veform, the user must use the update register (pwm_cupdx) to change waveform parameters while the channel is still enabled. the user can write a new period value or duty cycle value in the update re gister (cupdx). this register holds the new value until the end of the current cycle and updates the value for the next cycle. depending on the cpd field in the cmrx register, cupdx either updates cprdx or cdtyx. note that even if the update register is used, the period must not be smaller than the duty cycle.
522 32059l?avr32?01/2012 at32uc3b figure 24-6. synchronized period or duty cycle update to prevent overwriting the cupdx by software, the user can use status events in order to syn- chronize his software. two methods are possible. in both, the user must enable the dedicated interrupt in ier at pwm controller level. the first method (polling method) consists of r eading the relevant status bit in isr register according to the enabled channel(s). see figure 24-7 . the second method uses an interrupt serv ice routine associated with the pwm channel. note: reading the isr register automatically clears chidx flags. figure 24-7. polling method note: polarity and alignment can be modified only when the channel is disabled. user?s writing end of cycle cupdx value cmrx.cpd cprdx cdtyx 10 isr read acknoledgement and clear prev ious register state writing in cpd field update of the period or duty cycle chidx = 1 writing in cupdx the last write has been taken into account
523 32059l?avr32?01/2012 at32uc3b 24.6.3.4 interrupts depending on the interrupt mask in the imr register, an interrupt is generated at the end of the corresponding channel period. the interrupt remain s active until a read operation in the isr reg- ister occurs. a channel interrupt is enabled by setting the corresponding bit in the ier register. a channel interrupt is disabled by setting the corresponding bit in the idr register.
524 32059l?avr32?01/2012 at32uc3b 24.7 user interface table 24-2. pwm controller memory map offset register name access peripheral reset value 0x000 mode register mr read/write 0x00000000 0x004 enable register ena write-only - 0x008 disable register dis write-only - 0x00c status register sr read-only 0x00000000 0x010 interrupt enable register ier write-only - 0x014 interrupt disable register idr write-only - 0x018 interrupt mask register imr read-only 0x00000000 0x01c interrupt status register isr read-only 0x00000000 0x200 channel 0 mode register cmr0 read/write 0x00000000 0x204 channel 0 duty cycle register cdty0 read/write 0x00000000 0x208 channel 0 period register cprd0 read/write 0x00000000 0x20c channel 0 counter register ccnt0 read-only 0x00000000 0x210 channel 0 update register cupd0 write-only - 0x220 channel 1 mode register cmr1 read/write 0x00000000 0x224 channel 1 duty cycle register cdty1 read/write 0x00000000 0x228 channel 1 period register cprd1 read/write 0x00000000 0x22c channel 1 counter register ccnt1 read-only 0x00000000 0x230 channel 1 update register cupd1 write-only -
525 32059l?avr32?01/2012 at32uc3b 24.7.1 mode register name: mr access type: read/write offset: 0x000 reset value: 0x00000000 ? diva, divb: clka, clkb divide factor ? prea, preb 31 30 29 28 27 26 25 24 ???? preb 23 22 21 20 19 18 17 16 divb 15 14 13 12 11 10 9 8 ???? prea 76543210 diva diva, divb clka, clkb 0 clka, clkb clock is turned off 1 clka, clkb clock is clock selected by prea, preb 2-255 clka, clkb clock is clock selected by prea, preb divided by diva, divb factor. prea, preb divide r input clock 0000clk_pwm. 0001clk_pwm/2 0010clk_pwm/4 0011clk_pwm/8 0100clk_pwm/16 0101clk_pwm/32 0110clk_pwm/64 0111clk_pwm/128 1000clk_pwm/256 1001clk_pwm/512 1010clk_pwm/1024 other reserved
526 32059l?avr32?01/2012 at32uc3b 24.7.2 enable register name: ena access type: write-only offset: 0x004 reset value: - ? chidx: channel id 1: writing a one to this bit will enable pwm output for channel x. 0: writing a zero to this bit has no effect. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ? chid6 chid5 chid4 chid3 chid2 chid1 chid0
527 32059l?avr32?01/2012 at32uc3b 24.7.3 disable register name: dis access type: write-only offset: 0x008 reset value: - ? chidx: channel id 1: writing a one to this bit will disable pwm output for channel x. 0: writing a zero to this bit has no effect. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ? chid6 chid5 chid4 chid3 chid2 chid1 chid0
528 32059l?avr32?01/2012 at32uc3b 24.7.4 status register name: sr access type: read-only offset: 0x00c reset value: 0x00000000 ? chidx: channel id 0: pwm output for channel x is disabled. 1: pwm output for channel x is enabled. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ? chid6 chid5 chid4 chid3 chid2 chid1 chid0
529 32059l?avr32?01/2012 at32uc3b 24.7.5 interrupt enable register name: ier access type: write-only offset: 0x010 reset value: - writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ? chid6 chid5 chid4 chid3 chid2 chid1 chid0
530 32059l?avr32?01/2012 at32uc3b 24.7.6 interrupt disable register name: idr access type: write-only offset: 0x014 reset value: - writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ? chid6 chid5 chid4 chid3 chid2 chid1 chid0
531 32059l?avr32?01/2012 at32uc3b 24.7.7 interrupt mask register name: imr access type: read-only offset: 0x018 reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. a bit in this register is cleared when the corresponding bit in idr is written to one. a bit in this register is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ? chid6 chid5 chid4 chid3 chid2 chid1 chid0
532 32059l?avr32?01/2012 at32uc3b 24.7.8 interrupt status register name: isr access type: read-only offset: 0x01c reset value: 0x00000000 ? chidx: channel id 0 = no new channel period since the last read of the isr register. 1 = at least one new channel period since the last read of the isr register. note: reading isr automatically clears chidx flags. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ? chid6 chid5 chid4 chid3 chid2 chid1 chid0
533 32059l?avr32?01/2012 at32uc3b 24.7.9 channel mode register name: cmrx access type: read/write offset: 0x200 reset value: 0x00000000 ? cpd: channel update period 0 = writing a zero to this bit will modify the duty cycle at the next period start event. 1 = writing a one to this bit will modify the period at the next period start event. ? cpol: channel polarity 0 = writing a zero to this bit with configure the output waveform to start at a low level. 1 = writing a zero to this bit with configure the output waveform to start at a high level. ? calg: channel alignment 0 = writing a zero to this bit with configure the period to be left aligned. 1 = writing a zero to this bit with configure the period to be center aligned. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ?????cpdcpolcalg 76543210 ???? cpre
534 32059l?avr32?01/2012 at32uc3b ? cpre: channel pre-scaler cpre channel pre-scaler 0000clk_pwm 0001clk_pwm/2 0010clk_pwm/4 0011clk_pwm/8 0100clk_pwm/16 0101clk_pwm/32 0110clk_pwm/64 0111clk_pwm/128 1000clk_pwm/256 1001clk_pwm/512 1 0 1 0 clk_pwm/1024 1011clka 1100clkb other reserved
535 32059l?avr32?01/2012 at32uc3b 24.7.10 channel duty cycle register name: cdty x access type: read/write offset: 0x204 reset value: 0x00000000 only the first 20 bits (internal channel counter size) are significant. ? cdty: channel duty cycle defines the waveform duty cycle. this value must be defined between 0 and cprd (cprx). 31 30 29 28 27 26 25 24 cdty 23 22 21 20 19 18 17 16 cdty 15 14 13 12 11 10 9 8 cdty 76543210 cdty
536 32059l?avr32?01/2012 at32uc3b 24.7.11 channel period register name: cprdx access type: read/write offset: 0x208 reset value: 0x00000000 only the first 20 bits (internal channel counter size) are significant. ? cprd: channel period if the waveform is left-aligned, then the output waveform pe riod depends on the counter source clock and can be calculated: ? by using the master clock (clk_pwm) divi ded by an x given prescaler value (with x being 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, or 1024). the resulting period formula will be: ? by using a master clock divided by one of both diva or divb divider, the formula becomes, respectively: or if the waveform is center-aligned, then the output waveform period depends on the counter source clock and can be calculated: ? by using the master clock (clk_pwm) divi ded by an x given prescaler value (with x being 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, or 1024). the resulting period formula will be: ? by using a master clock divided by one of both diva or divb divider, the formula becomes, respectively: or 31 30 29 28 27 26 25 24 cprd 23 22 21 20 19 18 17 16 cprd 15 14 13 12 11 10 9 8 cprd 76543210 cprd xcprd () clk_pwm ------------------------------- crpd diva () clk_pwm ------------------------------------------ crpd divab () clk_pwm ---------------------------------------------- 2 x cprd () clk_pwm ---------------------------------------- - 2 cprd diva () clk_pwm --------------------------------------------------- - 2 cprd divb () clk_pwm --------------------------------------------------- -
537 32059l?avr32?01/2012 at32uc3b 24.7.12 channel counter register name: ccntx access type: read-only offset: 0x20c reset value: 0x00000000 ? cnt: channel counter register internal counter value. this register is reset when the counter reaches the cprd value defined in the cprdx register if the waveform is left aligned. 31 30 29 28 27 26 25 24 cnt 23 22 21 20 19 18 17 16 cnt 15 14 13 12 11 10 9 8 cnt 76543210 cnt
538 32059l?avr32?01/2012 at32uc3b 24.7.13 channel update register name: cupdx access type: write-only offset: 0x210 reset value: 0x00000000 this register acts as a double buffer for the period or t he duty cycle. this prevents an unexpe cted waveform when modifying the waveform period or duty-cycle. only the first 20 bits (internal channel counter size) are significant. 31 30 29 28 27 26 25 24 cupd 23 22 21 20 19 18 17 16 cupd 15 14 13 12 11 10 9 8 cupd 76543210 cupd ? cpd (cmrx register) 0 the duty-cycle (cdty in the cdtyx register) is updated with the cupd value at the beginning of the next period. 1 the period (cprd in the cprdx register) is updated with the cupd value at the beginning of the next period.
539 32059l?avr32?01/2012 at32uc3b 25. analog-to-digital converter (adc) rev: 2.0.0.1 25.1 features ? integrated multiplexer offering up to eight independent analog inputs ? individual enable and disable of each channel ? hardware or so ftware trigger ? external trigger pin ? timer counter outputs (corresponding tioa trigger) ? peripheral dma controller support ? possibility of adc timings configuration ? sleep mode and conversion sequencer ? automatic wakeup on trigger and back to sleep mode after conversions of all enabled channels 25.2 overview the analog-to-digital converter (adc) is based on a successive approximation register (sar) 10-bit adc. it also integrates an 8-to-1 analog mu ltiplexer, making possible the analog-to-digital conversions of 8 analog lines. the conversions extend from 0v to advref. the adc supports an 8-bit or 10-bit resolution mode, and conversion results are reported in a common register for all channels, as well as in a channel-dedicated register. software trigger, external trigger on rising edge of the trigger pin, or internal triggers from timer counter out- put(s) are configurable. the adc also integrates a sleep mode and a co nversion sequencer and connects with a periph- eral dma controller channel. these features reduce both power consumption and processor intervention. finally, the user can configure adc timings, such as startup time and sample & hold time.
540 32059l?avr32?01/2012 at32uc3b 25.3 block diagram figure 25-1. adc block diagram 25.4 i/o lines description 25.5 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 25.5.1 i/o lines the trigger pin may be shared with other peripheral functions through the i/o controller. table 25-1. adc pins description pin name description vddana analog power supply advref reference voltage ad[0] - ad[ 7] analog input channels trigger external trigger dedicated analog inputs analog inputs multiplexed with i/o lines gnd ad- ad- ad- ad- ad- ad- advref vddana trigger trigger selection adc control logic adc interrupt interrupt controller high speed bus (hsb) peripheral dma controller peripheral bridge peripheral bus (pb) user interface successive approximation register analog-to-digital converter i/o controller timer counter channels
541 32059l?avr32?01/2012 at32uc3b 25.5.2 power management in sleep mode, the adc clock is automatically stopped after each conversi on. as the logic is small and the adc cell can be put into sleep mode, the power manager has no effect on the adc behavior. 25.5.3 clocks the clock for the adc bus interface (clk_adc) is generated by the power manager. this clock is enabled at reset, and can be disabled in th e power manager. it is recommended to disable the adc before disabling the clock, to avoid freezing the adc in an undefined state. the clk_adc clock frequency must be in line wit h the adc characteritics. refer to electrical characteristics se ction for details. 25.5.4 interrupts the adc interrupt request line is connected to the interrupt cont roller. using the adc interrupt requires the interrupt controller to be programmed first. 25.5.5 analog inputs the analog input pins can be multiplexed with i/o lines. in this case, the assignment of the adc input is automatically done as soon as the corre sponding i/o is configured through the i/o con- toller. by default, after reset, the i/o line is configured as a logic input. 25.5.6 timer triggers timer counters may or may not be used as hardware triggers depending on user requirements. thus, some or all of the timer counters may be non-connected. 25.6 functional description 25.6.1 analog-to-digital conversion the adc uses the adc clock to perform conversi ons. converting a single analog value to a 10- bit digital data requires sample and hold clock cycles as defined in the sample and hold time field of the mode register (mr.shtim) and 10 adc clock cycles. the adc clock frequency is selected in the prescaler ra te selection field of the mr register (mr.prescal). the adc clock range is between clk_adc/2, if the prescal field is 0, and clk_adc/128, if the prescal field is 63 (0x3f). the prescal fiel d must be written in order to provide an adc clock frequency according to the parameters give n in the electrical characteristics chapter. 25.6.2 conversion reference the conversion is performed on a full range between 0v and the reference voltage pin advref. analog input values between these voltages are converted to digital values based on a linear conversion. 25.6.3 conversion resolution the adc supports 8-bit or 10-bit resolutions. the 8-bit selection is performed by writing a one to the resolution bit in the mr re gister (mr.lowres). by default, after a reset, the resolution is the highest and the converted data field in the channel data registers (cdrn.data) is fully used. by writing a one to the lo wres bit, the adc switches in the lowest resolution and the conversion results can be read in the eight lowest significant bits of the channel data registers (cdrn). the two highest bits of the data field in the corresponding cdrn register will be read
542 32059l?avr32?01/2012 at32uc3b as zero. the two highest bits of the last data converted field in the last converted data regis- ter (lcdr.ldata) will be read as zero too. moreover, when a peripheral dma channel is connec ted to the adc, a 10-b it resolution sets the transfer request size to 16-bit. writing a one to t he lowres bit automatically switches to 8-bit data transfers. in this case, the destination buffers are optimized. 25.6.4 conversion results when a conversion is completed, the resulting 10-b it digital value is stored in the cdr register of the current channel and in the lcdr register . channels are enabled by writing a one to the channel n enable bit (chn) in the cher register. the corresponding channel end of conversion bit in the status register (sr.eocn) and the data ready bit in the sr register (sr.drdy) are set. in the case of a connected peripheral dma channel, drdy rising trigge rs a data transfer request. in any case, either eoc or drdy can trigger an interrupt. reading one of the cdrn registers clears the corresponding eoc bit. reading lcdr clears the drdy bit and the eoc bit correspond ing to the last converted channel. figure 25-2. eocn and drdy flag behavior read lcdr write cr with start=1 read cdrn write cr with start=1 chn(chsr) eocn(sr) drdy(sr) conversion time conversion time
543 32059l?avr32?01/2012 at32uc3b if the cdr register is not read before further incoming data is converted, the corresponding overrun error bit in the sr register (sr.ovren) is set. in the same way, new data converted when drdy is high sets the general overrun error bit in the sr register (sr.govre). the ovren and govre bits are automatically cleared when the sr register is read. figure 25-3. govre and ovren flag behavior warning: if the corresponding channel is disabled during a conversion or if it is disabled and then reenabled during a conversion, its asso ciated data and its corre sponding eoc and ovre flags in sr are unpredictable. read sr data c data c data b data b data a data a undefined data undefined data undefined data lcdr crd0 ch1(chsr) ch0(chsr) trigger crd1 eoc0(sr) eoc1(sr) govre(sr) drdy(asr) ovre0(sr) read cdr0 read cdr1 conversion conversion conversion
544 32059l?avr32?01/2012 at32uc3b 25.6.5 conversion triggers conversions of the active analog channels are started with a software or a hardware trigger. the software trigger is provided by writing a one to the start bit in the control register (cr.start). the hardware trigger can be one of the tioa out puts of the timer counter channels, or the external trigger input of the adc (trigger). the hardware trigger is selected with the trigger selection field in the mode regi ster (mr.trigsel). the selected hardware trigger is enabled by writing a one to the trigger enable bit in the mode register (mr.trgen). if a hardware trigger is selected, the start of a c onversion is detected at each rising edge of the selected signal. if one of the tioa outputs is selected, the corresponding timer counter channel must be programmed in waveform mode. only one start command is necessa ry to initiate a conversion sequence on all the channels. the adc hardware logic automatically performs the conversions on the active channels, then waits for a new request. the channel enable (cher) and channel disable (chdr) registers enable the analog channels to be enabl ed or disabled independently. if the adc is used with a peripheral dma controller, only the transfers of converted data from enabled channels are performed and the resulting data buffers should be interpreted accordingly. warning: enabling hardware triggers does not disable th e software trigger fu nctionality. thus, if a hardware trigger is selected, the start of a conv ersion can be initiated either by the hardware or the software trigger. 25.6.6 sleep mode and conversion sequencer the adc sleep mode maximizes power saving by automatically deactivating the adc when it is not being used for conversions. sleep mode is se lected by writing a one to the sleep mode bit in the mode register (mr.sleep). the sleep mode is automatically managed by a conversion sequencer, which can automati- cally process the conversions of all c hannels at lowest power consumption. when a start conversion request occurs, the adc is automatically activated. as the analog cell requires a start-up time, the logic waits during this time and starts the conversion on the enabled channels. when all conversions are complete, the a dc is deactivated until the next trigger. trig- gers occurring during the sequence are not taken into account. the conversion sequencer allows automatic pr ocessing with minimum processor intervention and optimized power consumption. conversion sequences can be performed periodically using a timer/counter output. the periodic acquisitio n of several samples ca n be processed automat- ically without any intervention of the processor thanks to the peripheral dma controller. note: the reference voltage pins always remain connected in normal mode as in sleep mode.
545 32059l?avr32?01/2012 at32uc3b 25.6.7 adc timings each adc has its own minimal startup time that is defined through the start up time field in the mode register (mr.startup). this startup time is given in the electrical characteristics chapter. in the same way, a minimal sample and hold time is necessary for the adc to guarantee the best converted final value betwee n two channels selection. this time has to be defined through the sample and hold time field in the mode register (mr.shtim). this time depends on the input impedance of the analog input, but also on the output impedance of the driver providing the signal to the analog input, as there is no input buffer amplifier. 25.6.8 conversion performances for performance and electrical characteristics of the adc, see the electrical characteristics chapter.
546 32059l?avr32?01/2012 at32uc3b 25.7 user interface note: 1. the reset values are device specific. please refer to the module configuration section at the end of this chapter. table 25-2. adc register memory map offset register name access reset state 0x00 control register cr write-only 0x00000000 0x04 mode register mr read/write 0x00000000 0x10 channel enable register cher write-only 0x00000000 0x14 channel disable register chdr write-only 0x00000000 0x18 channel status register chsr read-only 0x00000000 0x1c status register sr read-only 0x000c0000 0x20 last converted data register lcdr read-only 0x00000000 0x24 interrupt enable register ier write-only 0x00000000 0x28 interrupt disable register idr write-only 0x00000000 0x2c interrupt mask register imr read-only 0x00000000 0x30 channel data register 0 cdr0 read-only 0x00000000 ... ...(if implemented) ... ... ... 0x4c channel data register 7(if implemented) cdr 7 read-only 0x00000000 0xfc version register version read-only - (1)
547 32059l?avr32?01/2012 at32uc3b 25.7.1 control register name: cr access type: write-only offset: 0x00 reset value: 0x00000000 ? start: start conversion writing a one to this bit will begi n an analog-to-di gital conversion. writing a zero to this bit has no effect. this bit always reads zero. ? swrst: software reset writing a one to this bit will reset the adc. writing a zero to this bit has no effect. this bit always reads zero. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ??????startswrst
548 32059l?avr32?01/2012 at32uc3b 25.7.2 mode register name: mr access type: read/write offset: 0x04 reset value: 0x00000000 ? shtim: sample & hold time sample & hold time = (shtim+3) / adcclock ? startup: start up time startup time = (startup+1) * 8 / adcclock this time should respect a minimal value. refer to electrical characteristics section for details. ? prescal: prescaler rate selection adcclock = clk_adc / ( (prescal+1) * 2 ) ? sleep: sleep mode 1: sleep mode is selected. 0: normal mode is selected. ? lowres: resolution 1: 8-bit resolution is selected. 0: 10-bit resolution is selected. ? trgsel: trigger selection ? trgen: trigger enable 1: the hardware trigger selected by the trgsel field is enabled. 0: the hardware triggers are disabled. starting a conversion is only possible by software. 31 30 29 28 27 26 25 24 ???? shtim 23 22 21 20 19 18 17 16 ?startup 15 14 13 12 11 10 9 8 prescal 76543210 ? ? sleep lowres trgsel trgen trgsel selected trgsel 0 0 0 internal trigger 0, depending of chip integration 0 0 1 internal trigger 1, depending of chip integration 0 1 0 internal trigger 2, depending of chip integration 0 1 1 internal trigger 3, depending of chip integration 1 0 0 internal trigger 4, depending of chip integration 1 0 1 internal trigger 5, depending of chip integration 1 1 0 external trigger
549 32059l?avr32?01/2012 at32uc3b 25.7.3 channel enable register name: cher access type: write-only offset: 0x10 reset value: 0x00000000 ? chn: channel n enable writing a one to these bits will set the corresponding bit in chsr. writing a zero to these bits has no effect. these bits always read a zero. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ch7 ch6 ch5 ch4 ch3 ch2 ch1 ch0
550 32059l?avr32?01/2012 at32uc3b 25.7.4 channel disable register name: chdr access type: write-only offset: 0x14 reset value: 0x00000000 ? chn: channel n disable writing a one to these bits will clear the corresponding bit in chsr. writing a zero to these bits has no effect. these bits always read a zero. warning: if the corresponding channel is disabled during a conversion or if it is disabled then reenabled during a conversion, its associated data and its corresponding eoc and ovre flags in sr are unpredictable. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ch7 ch6 ch5 ch4 ch3 ch2 ch1 ch0
551 32059l?avr32?01/2012 at32uc3b 25.7.5 channel status register name: chsr access type: read-only offset: 0x18 reset value: 0x00000000 ? chn: channel n status these bits are set when the corresponding bits in cher is written to one. these bits are cleared when the corresponding bits in chdr is written to one. 1: the corresponding channel is enabled. 0: the corresponding channel is disabled. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ch7 ch6 ch5 ch4 ch3 ch2 ch1 ch0
552 32059l?avr32?01/2012 at32uc3b 25.7.6 status register name: sr access type: read-only offset: 0x1c reset value: 0x000c0000 ? rxbuff: rx buffer full this bit is set when the buffer full signal from the peripheral dma is active. this bit is cleared when the buffer full signal from the receive peripheral dma is inactive. ? endrx: end of rx buffer this bit is set when the end receive signal from the peripheral dma is active. this bit is cleared when the end receive signal from the peripheral dma is inactive. ? govre: general overrun error this bit is set when a general overrun error has occurred. this bit is cleared when the sr register is read. 1: at least one general overrun error has occurred since the last read of the sr register. 0: no general overrun error occurred since the last read of the sr register. ? drdy: data ready this bit is set when a data has been converted and is available in the lcdr register. this bit is cleared when the lcdr register is read. 0: no data has been converted since the last read of the lcdr register. 1: at least one data has been converted and is available in the lcdr register. ? ovren: overrun error n these bits are set when an overrun error on the corresponding channel has occurred (if implemented). these bits are cleared when the sr register is read. 0: no overrun error on the corresponding channel (if implemented) since the last read of sr. 1: there has been an overrun error on the corresponding channel (if implemented) since the last read of sr. ? eocn: end of conversion n these bits are set when the corresponding conversion is complete. these bits are cleared when the corresponding cdr or lcdr registers are read. 0: corresponding analog channel (if implemented) is disabled, or the conversion is not finished. 1: corresponding analog channel (if implemente d) is enabled and conversion is complete. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ????rxbuffendrxgovre drdy 15 14 13 12 11 10 9 8 ovre7 ovre6 ovre5 ovre4 ovre3 ovre2 ovre1 ovre0 76543210 eoc7 eoc6 eoc5 eoc4 eoc3 eoc2 eoc1 eoc0
553 32059l?avr32?01/2012 at32uc3b 25.7.7 last converted data register name: lcdr access type: read-only offset: 0x20 reset value: 0x00000000 ? ldata: last data converted the analog-to-digital conversion data is placed into this regist er at the end of a conversion and remains until a new conversio n is completed. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ?????? ldata[9:8] 76543210 ldata[7:0]
554 32059l?avr32?01/2012 at32uc3b 25.7.8 interrupt enable register name: ier access type: write-only offset: 0x24 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ????rxbuffendrxgovre drdy 15 14 13 12 11 10 9 8 ovre7 ovre6 ovre5 ovre4 ovre3 ovre2 ovre1 ovre0 76543210 eoc7 eoc6 eoc5 eoc4 eoc3 eoc2 eoc1 eoc0
555 32059l?avr32?01/2012 at32uc3b 25.7.9 interrupt disable register name: idr access type: write-only offset: 0x28 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ????rxbuffendrxgovre drdy 15 14 13 12 11 10 9 8 ovre7 ovre6 ovre5 ovre4 ovre3 ovre2 ovre1 ovre0 76543210 eoc7 eoc6 eoc5 eoc4 eoc3 eoc2 eoc1 eoc0
556 32059l?avr32?01/2012 at32uc3b 25.7.10 interrupt mask register name: imr access type: read-only offset: 0x2c reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. a bit in this register is cleared when the corresponding bit in idr is written to one. a bit in this register is cleared when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ????rxbuffendrxgovre drdy 15 14 13 12 11 10 9 8 ovre7 ovre6 ovre5 ovre4 ovre3 ovre2 ovre1 ovre0 76543210 eoc7 eoc6 eoc5 eoc4 eoc3 eoc2 eoc1 eoc0
557 32059l?avr32?01/2012 at32uc3b 25.7.11 channel data register name: cdrx access type: read-only offset: 0x2c-0x4c reset value: 0x00000000 ? data: converted data the analog-to-digital conversion data is placed into this regist er at the end of a conversion and remains until a new conversio n is completed. the convert data register (cdr) is onl y loaded if the corresponding analog channel is enabled. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ?????? data[9:8] 76543210 data[7:0]
558 32059l?avr32?01/2012 at32uc3b 25.7.12 version register name: version access type: read-only offset: 0xfc reset value: ? ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???? variant 15 14 13 12 11 10 9 8 ???? version[11:8] 76543210 version[7:0]
559 32059l?avr32?01/2012 at32uc3b 25.8 module configuration the specific configuration for the adc in stance is listed in the following tables. table 25-3. module configuration feature adc number of channels 8 internal trigger 0 tioa ouput a of the timer counter channel 0 internal trigger 1 tiob ouput b of the timer counter channel 0 internal trigger 2 tioa ouput a of the timer counter channel 1 internal trigger 3 tiob ouput b of the timer counter channel 1 internal trigger 4 tioa ouput a of the timer counter channel 2 internal trigger 5 tiob ouput b of the timer counter channel 2 table 25-4. module clock name module name clock name adc clk_adc table 25-5. register reset values module name reset value version 0x00000200
560 32059l?avr32?01/2012 at32uc3b 26. audio bitstream dac (abdac) rev: 1.0.1.1 26.1 features ? digital stereo dac ? oversampled d/a conversion architecture ? oversampling ratio fixed 128x ? fir equalization filter ? digital interpolation filter: comb4 ? 3rd order sigma-delta d/a converters ? digital bitstream outputs ? parallel interface ? connected to dma controller for background transfer without cpu intervention 26.2 overview the audio bitstream dac converts a 16-bit samp le value to a digital bitstream with an average value proportional to the sample value. tw o channels are supported, making the audio bit- stream dac particularly suitable for stereo audio. each channel has a pair of complementary digital outputs, datan and datann, which can be connected to an external high input imped- ance amplifier. the output datan and datann should be as ideal as possible before filtering, to achieve the best snr and thd quality. the outputs can be connected to a class d amplifier output stage to drive a speaker directly, or it can be low pass filtered and connected to a high input impedance amplifier. a simple 1st order low pass filter that filters all the frequencies above 50khz should be adequate when applying the signal to a speaker or a bandlimited amplifier, as the speaker or amplifier will act as a filter and remove high frequency components from the signal. in some cases high frequency components might be folded down into the audible range, and in that case a higher order filter is required. for perform ance measurements on digital equipment a minimum of 4th order low pass filter should be used. this is to prevent aliasing in the measurements. for the best performance when not using a clas s d amplifier approach, the two outputs datan and datann, should be applied to a differential st age amplifier, as this will increase the snr and thd.
561 32059l?avr32?01/2012 at32uc3b 26.3 block diagram figure 26-1. abdac block diagram 26.4 i/o lines description 26.5 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 26.5.1 i/o lines the output pins used for the ou tput bitstream from the audio bitstream dac may be multiplexed with io lines. before using the audio bitstream dac, the i/o controller must be configured in order for the audio bitstream dac i/o lines to be in audio bitstream dac peripheral mode. table 26-1. i/o lines description pin name pin description type data0 output from audio bitstream dac channel 0 output data1 output from audio bitstream dac channel 1 output datan0 inverted output from audio bitstream dac channel 0 output datan1 inverted output from audio bitstream dac channel 1 output clock generator equalization fir comb (int=128) sigma-delta da-mod equalization fir comb (int=128) sigma-delta da-mod bit_clk data0 data1 gclk_abdac sample_clk channel0[15:0] audio bitstream dac pm user interface channel1[15:0]
562 32059l?avr32?01/2012 at32uc3b 26.5.2 clocks the clk_abdac to the audio bitstream dac is generated by the power manager (pm). before using the audio bitstream dac, the user must ensure that t he audio bitstream dac clock is enabled in the power manager. the abdac needs a separate clock for the d/a conversion operation. this clock, gclk_abdac should be set up in the generic clock register in the power manager and its fre- quency must be as follow: where f s is the samping rate of the data stream to convert. for f s = 48khz this means that the gclk_abdac clock must have a frequency of 12.288mhz. the two clocks, clk_abdac and gclk_abdac , must be in phase with each other. 26.5.3 interrupts the abdac interrupt request line is connected to the interrupt controller. using the abdac interrupt requires the interrupt controller to be programmed first. 26.6 functional description 26.6.1 how to initialize the module in order to use the audio bitstrea m dac the product dependencies given in section 26.5 on page 561 must be resolved. particular attention should be given to the configurat ion of clocks and i/o lines in order to ensure correct operation of the audio bitstream dac. the audio bitstream dac is enabled by writing a one to the enable bit in the audio bitstream dac control register (cr.en). the transmit ready interrupt status bit in th e interrupt status register (isr.txready) will be set whenever the abdac is ready to receive a ne w sample. a new sample value should be writ- ten to sdr before 256 abdac cl ock cycles, or an unde rrun will occur, as indicated by the underrun interrupt status bit in isr (isr.unde rrun). isr is cleared when read, or when writ- ing one to the corresponding bits in the interrupt clear register (icr). 26.6.2 data format the input data format is two?s complement. two 16-bit sample values for channel 0 and 1 can be written to the least and most significant halfword of the sample data register (sdr), respectively. an input value of 0x7fff will result in an output voltage of approximately: an input value of 0x8000 will result in an output value of approximately: f gclk 256 f s = v out 0 x 7 fff () 38 128 --------- - vddio 38 128 --------- - 33 , ? 0 98 v , = ? v out 0 x 8000 () 90 128 --------- - vddio 90 128 --------- - 33 , ? 2 32 v , = ?
563 32059l?avr32?01/2012 at32uc3b if one want to get coherence between the sign of the input data and the output voltage one can use the datan signal or invert the sign of the input data by software. 26.6.3 data swapping when the swap bit in the abdac control register (cr. swap) is written to one, writing to the sample data register (sdr) will cause the values written to the channel0 and channel1 fields to be swapped. 26.6.4 peripheral dma controller the audio bitstream dac is connected to the peripheral dma controller. the peripheral dma controller can be programmed to automatically transfer samples to the audio bitstream dac sample data register (sdr) when the audio bits tream dac is ready for new samples. in this case only the cr.en bit needs to be set in the audio bitstream dac module. this enables the audio bitstream dac to operate without any cpu intervention such as polling the interrupt sta- tus register (isr) or using interrupts. see the peripheral dma controller documentation for details on how to setup peripheral dma transfers. 26.6.5 construction the audio bitstream dac is constructed of two 3rd order sigma-delta d/a converter with an oversampling ratio of 128. the samples are upsampl ed with a 4th order sinc interpolation filter (comb4) before being applied to the sigma-delta modulator. in order to compensate for the pass band frequency response of the interpolation filter and flatten the overall frequency response, the input to the interpolation filter is fi rst filtered with a simple 3-tap fir filter.the total frequency response of the equalization fir filt er and the interpolation filter is given in figure 26- 2 on page 564 . the digital output bitstreams from the sigma-delta modulators should be low- pass filtered to remove high frequency noise inserted by the modulation process. 26.6.6 equalization filter the equalization filter is a simple 3-tap fir filter. the purpose of th is filter is to compensate for the pass band frequency response of the sinc in terpolation filter. the equalization filter makes the pass band response more flat and moves the -3db corner a little higher. 26.6.7 interpolation filter the interpolation filter interpolates from f s to 128f s . this filter is a 4thorder cascaded integrator- comb filter, and the basi c building blocks of this filter is a comb part and an integrator part. 26.6.8 sigma-delta modulator this part is a 3rdorder sigma- delta modulator consisting of thre e differentiators (delta blocks), three integrators (sigma blocks) and a one bit quantizer. the purpose of the integrators is to shape the noise, so that the noise is reduced in the band of interest and increased at the higher frequencies, where it can be filtered.
564 32059l?avr32?01/2012 at32uc3b 26.6.9 frequency response figure 26-2. frequency response, eq-fir+comb 4 0 1 2 3 4 5 6 7 8 9 10 x 10 4 -6 0 -5 0 -4 0 -3 0 -2 0 -1 0 0 10 frequenc y [f s] a m p litud e [db ]
565 32059l?avr32?01/2012 at32uc3b 26.7 user interface table 26-2. abdac register memory map offset register register name access reset 0x00 sample data register sdr read/write 0x00000000 0x08 control register cr read/write 0x00000000 0x0c interrupt mask register imr read-only 0x00000000 0x10 interrupt enable register ier write-only 0x00000000 0x14 interrupt disable register idr write-only 0x00000000 0x18 interrupt clear register icr write-only 0x00000000 0x1c interrupt status register isr read-only 0x00000000
566 32059l?avr32?01/2012 at32uc3b 26.7.1 sample data register name: sdr access type: read/write offset: 0x00 reset value: 0x00000000 ? channel1: sample data for channel 1 signed 16-bit sample data for channel 1. ? channel0: signed 16-bit sample data for channel 0 signed 16-bit sample data for channel 0. 31 30 29 28 27 26 25 24 channel1[15:8] 23 22 21 20 19 18 17 16 channel1[7:0] 15 14 13 12 11 10 9 8 channel0[15:8] 76543210 channel0[7:0]
567 32059l?avr32?01/2012 at32uc3b 26.7.2 control register name: cr access type: read/write offset: 0x08 reset value: 0x00000000 ? en: enable audio bitstream dac 1: the module is enabled. 0: the module is disabled. ? swap: swap channels 1: the swap of channel0 and channel1 samples is enabled. 0: the swap of channel0 and channel1 samples is disabled. 31 30 29 28 27 26 25 24 enswap------ 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 --------
568 32059l?avr32?01/2012 at32uc3b 26.7.3 interrupt mask register name: imr access type: read-only offset: 0x0c reset value: 0x00000000 1: the corresponding interrupt is enabled. 0: the corresponding interrupt is disabled. a bit in this register is set when the corresponding bit in ier is written to one. a bit in this register is cleared when the corresponding bit in idr is written to one. 31 30 29 28 27 26 25 24 --txreadyunderrun---- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 --------
569 32059l?avr32?01/2012 at32uc3b 26.7.4 interrupt enable register name: ier access type: write-only offset: 0x10 reset value: 0x00000000 writing a one to a bit in this register will set the corresponding bit in imr. writing a zero to a bit in this register has no effect. 31 30 29 28 27 26 25 24 --txreadyunderrun---- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 --------
570 32059l?avr32?01/2012 at32uc3b 26.7.5 interrupt disable register name: idr access type: write-only offset: 0x14 reset value: 0x00000000 writing a one to a bit in this register will clear the corresponding bit in imr. writing a zero to a bit in this register has no effect. 31 30 29 28 27 26 25 24 --txreadyunderrun---- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 --------
571 32059l?avr32?01/2012 at32uc3b 26.7.6 interrupt clear register name: icr access type: write-only offset: 0x18 reset value: 0x00000000 writing a one to a bit in this register will clear the corresponding bit in isr and the corresponding interrupt request. writing a zero to a bit in this register has no effect. 31 30 29 28 27 26 25 24 --txreadyunderrun---- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 --------
572 32059l?avr32?01/2012 at32uc3b 26.7.7 interrupt status register name: isr access type: read-only offset: 0x1c reset value: 0x00000000 ? txready: tx ready interrupt status this bit is set when the audio bitstream dac is ready to receive a new data in sdr. this bit is cleared when the audio bitstream da c is not ready to receive a new data in sdr. ? underrun: underrun interrupt status this bit is set when at least one audio bitstream dac underrun ha s occurred since the last time this bit was cleared (by reset or by writing in icr). this bit is cleared when no audio bitstream dac underrun has occu rred since the last time this bit was cleared (by reset or by writing in icr). 31 30 29 28 27 26 25 24 --txreadyunderrun---- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 --------
573 32059l?avr32?01/2012 at32uc3b 27. programming and debugging 27.1 overview general description of programming and debug features, block diagram and introduction of main concepts. 27.2 service access bus the avr32 architecture offers a common interf ace for access to on-chip debug, programming, and test functions. these are mapped on a common bus called t he service acce ss bus (sab), which is linked to the jtag port through a bus master module, which also handles synchroniza- tion between the debu gger and sab clocks. when accessing the sab through th e debugger ther e are no limitations on debugger frequency compared to chip frequency, although there must be an active system clock in order for the sab accesses to complete. if the system clock is swit ched off in sleep mode, activity on the debugger will restart the system clock automatically, without waking the device from sleep. debuggers may optimize the transfer rate by adjusting the frequency in relation to the system clock. this ratio can be measured with debug protocol specific instructions. the service access bus uses 36 address bits to address memory or registers in any of the slaves on the bus. the bus supports sized accesses of bytes (8 bits), halfwords (16 bits), or words (32 bits). all accesses must be aligned to the size of th e access, i.e. halfword accesses must have the lowest address bit cleared, and wo rd accesses must have the two lowest address bits cleared. 27.2.1 sab address map the service access bus (sab) gives the user ac cess to the internal address space and other features through a 36 bits address space. the 4 msbs identify the slave number, while the 32 lsbs are decoded within the slave?s address space. the sab slaves are shown in table 27-1 on page 573 . 27.2.2 sab security restrictions the service access bus can be restricted by internal security measures. a short description of the security measures are found in the table below. table 27-1. sab slaves, addresses and descriptions. slave address [35:32] description unallocated 0x0 intentionally unallocated ocd 0x1 ocd registers hsb 0x4 hsb memory space, as seen by the cpu hsb 0x5 alternative mapping for hsb sp ace, for compatibility with other 32-bit avr devices. memory service unit 0x6 memory service unit registers reserved other unused
574 32059l?avr32?01/2012 at32uc3b 27.2.2.1 security measure and control location a security measure is a mechanism to either block or a llow sab access to a certain address or address range. a security measure is enabled or disabled by one or several control signals. this is called the control location for the security measure. these security measures can be used to prevent an end user from reading out the code pro- grammed in the flash, for instance. below follows a more in depth description of what locations are accessible when the security measures are active. table 27-2. sab security measures. security measure control location description security bit flashc security bit set programming and debugging not possible, very restricted access. user code programming flashc uprot + security bit set restricts all access except parts of the flash and the flash controller for programming user code. debugging is not possible unless an os running from the secure part of the flash supports it. table 27-3. security bit sab restrictions name address start address end access ocd dccpu, ocd dcemu, ocd dcsr 0x100000110 0x100000118 read/write user page 0x580800000 0x581000000 read other accesses - - blocked table 27-4. user code programming sab restrictions name address start address end access ocd dccpu, ocd dcemu, ocd dcsr 0x100000110 0x100000118 read/write user page 0x580800000 0x581000000 read flashc pb interface 0x5fffe0000 0x5fffe0400 read/write flash pages outside bootprot 0x580000000 + bootprot size 0x580000000 + flash size read/write other accesses - - blocked
575 32059l?avr32?01/2012 at32uc3b 27.3 on-chip debug (ocd) rev: 1.4.3.1 27.3.1 features ? debug interface in complian ce with ieee-isto 5001-2 003 (nexus 2.0) class 2+ ? jtag access to all on-chip debug functions ? advanced program, data, ownership, and watchpoint trace supported ? nanotrace jtag-based trace access ? auxiliary port for high-speed trace information ? hardware support for 6 program and 2 data breakpoints ? unlimited number of software breakpoints supported ? automatic crc check of memory regions 27.3.2 overview debugging on the at32uc3b is facilitated by a powerful on-chip debug (ocd) system. the user accesses this through an external debug tool which connects to the jtag port and the aux- iliary (aux) port. the aux port is primarily used for trace functi ons, and a jtag-based debugger is sufficient for basic debugging. the debug system is based on the nexus 2.0 standard, class 2+, which includes: ? basic run-time control ? program breakpoints ? data breakpoints ? program trace ? ownership trace ? data trace in addition to the mandatory nexus debug features, the at32uc3b implements several useful ocd features, such as: ? debug communication channel between cpu and jtag ? run-time pc monitoring ? crc checking ? nanotrace ? software quality assurance (sqa) support the ocd features are controlled by ocd registers, which can be accessed by jtag when the nexus_access jtag instruction is loaded. the cpu can also access ocd registers directly using mtdr/mfdr instruct ions in any privileged mode. the ocd registers are implemented based on the recommendations in the nexus 2.0 stan dard, and are detailed in the avr32uc technical reference manual.
576 32059l?avr32?01/2012 at32uc3b 27.3.3 block diagram figure 27-1. on-chip debug block diagram 27.3.4 jtag-based debug features a debugger can control all ocd features by writ ing ocd registers over the jtag interface. many of these do not depend on output on the aux port, allowing a jtag-based debugger to be used. a jtag-based debugger should connect to the devi ce through a standard 10-pin idc connector as described in the avr32uc technical reference manual. on-chip debug jtag debug pc debug instruction cpu breakpoints program trace data trace ownership trace watchpoints transmit queue aux jtag internal sram s e r v i c e a c c e s s b u s memory service unit hsb bus matrix memories and peripherals
577 32059l?avr32?01/2012 at32uc3b figure 27-2. jtag-based debugger 27.3.4.1 debug communication channel the debug communication channel (d cc) consists of a pair ocd registers with associated handshake logic, accessible to both cpu an d jtag. the registers can be used to exchange data between the cpu and the jtag master, both runtime as well as in debug mode. 27.3.4.2 breakpoints one of the most fundamental debug features is the abilit y to halt the cpu, to examine registers and the state of the system. this is accomplish ed by breakpoints, of which many types are available: ? unconditional breakpoints are set by writing ocd registers by jtag, halting the cpu immediately. ? program breakpoints halt the cpu when a s pecific address in the program is executed. ? data breakpoints halt the cpu when a specific me mory address is read or written, allowing variables to be watched. ? software breakpoints halt the cpu when the breakpoint instruction is executed. when a breakpoint triggers, the cpu enters debug mode, and the d bit in the status register is set. this is a privileged mode with dedicated return address and return status registers. all privi- leged instructions are permitted. debug mode can be entered as either ocd mode, running instructions from jtag, or monitor mode, running instructions from program memory. avr32 jtag-based debug tool pc jtag 10-pin idc
578 32059l?avr32?01/2012 at32uc3b 27.3.4.3 ocd mode when a breakpoint triggers, the cpu enters ocd mode, and instructions are fetched from the debug instruction ocd register. each time this r egister is written by jtag, the instruction is executed, allowing the jtag to execute cpu instructions directly. the jtag master can e.g. read out the register file by issuing mtdr instructions to the cpu, writing each register to the debug communication channel ocd registers. 27.3.4.4 monitor mode since the ocd registers are directly accessible by the cpu, it is possible to build a software- based debugger that runs on the cpu itself. setting the monitor mode bit in the development control register causes the cpu to enter monitor mode instead of ocd mode when a breakpoint triggers. monitor mode is similar to ocd mode, e xcept that instructions are fetched from the debug exception vector in regular program memory, instead of issued by jtag. 27.3.4.5 program counter monitoring normally, the cpu would need to be halted for a jtag-based debugger to examine the current pc value. however, the at32uc3b provides a debug program counter ocd register, where the debugger can continuously read the current pc without affecting the cpu. this allows the debugger to generate a simple statistic of the time spent in various areas of the code, easing code optimization. 27.3.5 memory service unit the memory service unit (msu) is a block dedicated to test and debug functionality. it is con- trolled through a dedicated set of registers addressed through the memory_service jtag command. 27.3.5.1 cyclic redundancy check (crc) the msu can be used to automatically calculate the crc of a block of data in memory. the ocd will then read out each word in the specified memory bloc k and report the crc32-value in an ocd register. 27.3.5.2 nanotrace the msu additionally supports nanotrace. this is an avr32-specific feature, in which trace data is output to memory instead of the aux port. this allo ws the trace data to be extracted by jtag memory_access, enabling trace features for jtag-bas ed debuggers. the user must write msu registers to configure the address and size of the memory block to be used for nano- trace. the nanotrace buffer can be anywhere in th e physical address range, including internal and external ram, through an ebi, if present. th is area may not be used by the application run- ning on the cpu. 27.3.6 aux-based debug features utilizing the auxiliary (aux) port gives access to a wide range of advanced debug features. of prime importance are the trace features, which allow an external debugger to receive continuous information on the program execution in the cp u. additionally, event in and event out pins allow external events to be correlated with the program flow. the aux port contains a number of pins, as shown in table 27-5 on page 579 . these are multi- plexed with i/o controller lines , and must explicitly be enabled by writing ocd registers before the debug session starts. the aux port is mapped to two different location s, selectable by ocd registers, minimizing the chance that the aux port w ill need to be shared with an application.
579 32059l?avr32?01/2012 at32uc3b debug tools utilizing the aux port should connect to the device through a nexus-compliant mic- tor-38 connector, as described in the avr32uc technical reference manual. this connector includes the jtag signals and the reset_n pin, giving full access to the programming and debug features in the device. figure 27-3. aux+jtag based debugger 27.3.6.1 trace operation trace features are enabled by wr iting ocd registers by jtag. the ocd extracts the trace infor- mation from the cpu, compresses this information and formats it into variable-length messages according to the nexus standard. the messages are buffered in a 16-frame transmit queue, and are output on the aux port one frame at a time. table 27-5. auxiliary port signals signal direction description mcko output trace data output clock mdo[5:0] output trace data output mseo[1:0] output trace frame control evti_n input event in evto_n output event out avr32 aux+jtag debug tool jtag aux high speed mictor38 trace buffer pc
580 32059l?avr32?01/2012 at32uc3b the trace features can be configured to be very selective, to reduce the bandwidth on the aux port. in case the transmit queue overflows, er ror messages are produced to indicate loss of data. the transmit queue module can optionally be configured to halt the cpu when an overflow occurs, to prevent the loss of messages, at the expense of longer run-time for the program. 27.3.6.2 program trace program trace allows the debugger to continuously monitor the program execution in the cpu. program trace messages are generated for every branch in the program, and contains com- pressed information, which allows the debugger to correlate the message with the source code to identify the branch instruction and target address. 27.3.6.3 data trace data trace outputs a message every time a specific location is read or written. the message contains information about the type (read/write) and size of the access, as well as the address and data of the accessed location. the at32uc3 b contains two data trace channels, each of which are controlled by a pair of ocd registers which determine the range of addresses (or sin- gle address) which should produce data trace messages. 27.3.6.4 ownership trace program and data trace operate on virtual addres ses. in cases where an operating system runs several processes in overlapping virtual memory segments, the ownership trace feature can be used to identify th e process switch. w hen the o/s activates a proces s, it will write the process id number to an ocd register, which produces an ownership trace message, allowing the debug- ger to switch context for the subsequent program and data trace messages. as the use of this feature depends on the software running on the cpu, it can also be used to extract other types of information from the system. 27.3.6.5 watchpoint messages the breakpoint modules normally used to generate program and data breakpoints can also be used to generate watchpoint messages, allowing a debugger to monitor program and data events without halting the cpu. watchpoints can be enabled independently of breakpoints, so a breakpoint module can optionally halt the cpu when the trigger condition occurs. data trace modules can also be configured to produce watc hpoint messages instead of regular data trace messages. 27.3.6.6 event in and event out pins the aux port also contains an event in pin (evti_n) and an event out pin (evto_n). evti_n can be used to trigger a breakpoint when an external event occurs. it can also be used to trigger specific program and data trace synchronization messages, allowing an external event to be correlated to the program flow. when the cpu enters debug mode, a debug status message is transmitted on the trace port. all trace messages can be timestamped when they are received by the debug tool. however, due to the latency of the trans mit queue buffering, the timest amp will not be 100% accurate. to improve this, evto_n can toggle every time a message is inserted into the transmit queue, allowing trace messages to be timestamped prec isely. evto_n can also toggle when a break- point module triggers, or when the cpu enters debug mode, for any reason. this can be used to measure precisely when the respective internal event occurs.
581 32059l?avr32?01/2012 at32uc3b 27.3.6.7 software quality analysis (sqa) software quality analysis (sqa) deals with two important issues regarding embedded software development. code coverage involves identifying untested parts of the embedded code, to improve test procedures and thus t he quality of the released software. performance analysis allows the developer to precisely quantify the time spent in vari ous parts of the code, allowing bottlenecks to be identified and optimized. program trace must be used to accomplish thes e tasks without instrumenting (altering) the code to be examined. however, traditional program tr ace cannot reconstruct the current pc value without correlating the trace information with the source code, which cannot be done on-the-fly. this limits program trace to a relatively short time segment, determined by the size of the trace buffer in the debug tool. the ocd system in at32uc3b extends program trace with sqa capabilities, allowing the debug tool to reconstruct the pc value on-the-f ly. code coverage and performance analysis can thus be reported for an unlimited execution sequence.
582 32059l?avr32?01/2012 at32uc3b 27.4 jtag and boundary-scan (jtag) rev: 2.0.1.4 27.4.1 features ? ieee1149.1 compliant jtag interface ? boundary-scan chain for board-level testing ? direct memory access and programming capabilities through jtag interface 27.4.2 overview the jtag interface offers a four pin progra mming and debug solution, including boundary-scan support for board-level testing. figure 27-4 on page 583 shows how the jtag is connected in an 32-bit avr device. the tap controller is a state machine controlled by the tck and tms signals. the tap controller selects either the jtag instruction register or one of several data registers as the scan chain (shift register) between the tdi-input and tdo-output. the instruction register holds jt ag instructions controlling the be havior of a data register. the device identification register, bypass register, and the boundary-scan chain are the data reg- isters used for board-level testing. the reset register can be used to keep the device reset during test or programming. the service access bus (sab) interface cont ains address and data registers for the service access bus, which gives access to on-chip de bug, programming, and other functions in the device. the sab offers se veral modes of access to the addr ess and data regist ers, as described in section 27.4.11 . section 27.5 lists the supported jtag instructions, wit h references to the description in this document.
583 32059l?avr32?01/2012 at32uc3b 27.4.3 block diagram figure 27-4. jtag and boundary-scan access 27.4.4 i/o lines description 27.4.5 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 27.4.5.1 i/o lines the tms, tdi, and tdo pins are multiplexed with i/o lines. when the jtag is used the associ- ated pins must be enabled. to enable the jtag pins, refer to section 27.4.7 . table 27-6. i/o line description pin name pin description type active level tck test clock input. fully asynchronous to system clock frequency. input tms test mode select, sampled on rising tck. input tdi test data in, sampled on rising tck. input tdo test data out, driven on falling tck. output 32-bit avr device jtag data registers tap controller instruction register device identification register by-pass register reset register service access bus interface boundary scan chain pins and analog blocks data register scan enable jtag pins boundary scan enable 2nd jtag device jtag master tdi tdo part specific registers ... tdo tdi tms tms tck tck instruction register scan enable sab internal i/o lines jtag tms tdi tdo tck
584 32059l?avr32?01/2012 at32uc3b while using the multiplexed jtag lines all norma l peripheral activity on these lines is disabled. the user must make sure that no external peripheral is blocking the jtag lines while debugging. 27.4.5.2 power management when an instruction that accesses the sab is l oaded in the instruction register, before entering a sleep mode, the system clocks are not switched off to a llow debugging in sleep modes. this can lead to a program behaving differently when debugging. 27.4.5.3 clocks the jtag interface uses the external tck pin as clock source. this clock must be provided by the jtag master. instructions that use the sab bus requires the internal main clock to be running. 27.4.6 jtag interface the jtag interface is accessed thro ugh the dedicated jtag pins shown in table 27-6 on page 583 . the tms control line navigates t he tap controller, as shown in figure 27-5 on page 585 . the tap controller manages the serial access to the jtag instruction and data registers. data is scanned into the selected instru ction or data register on tdi, and out of the register on tdo, in the shift-ir and shift-dr states , respectively. the lsb is shifted in and out first. tdo is high- z in other states than shift-ir and shift-dr. the device implements a 5-bit inst ruction register (ir). a number of public jtag instructions defined by the jtag standard are supported, as described in section 27.5.2 , as well as a num- ber of 32-bit avr-specific private jtag instructions described in section 27.5.3 . each instruction selects a specific data register for the shift-dr path, as described for each instruction.
585 32059l?avr32?01/2012 at32uc3b figure 27-5. tap controller state diagram test-logic- reset run-test/ idle select-dr scan select-ir scan capture-dr capture-ir shift-dr shift-ir exit1-dr exit1-ir pause-dr pause-ir exit2-dr exit2-ir update-dr update-ir 0 1 1 1 0 0 1 0 1 1 0 0 1 0 1 1 1 0 1 1 0 0 1 1 0 1 0 0 0 0 0 1
586 32059l?avr32?01/2012 at32uc3b 27.4.7 how to initialize the module to enable the tms, tdi and tdo pins o ne clock pulse should be applied on tck. independent of the initial state of the tap contro ller, the test-logic-reset state can always be entered by holding tms high for 5 tck clock periods. this sequence should always be applied at the start of a jtag session and after enablin g the jtag pins to bring the tap controller into a defined state before applying jtag commands. applying a 0 on tms for 1 tck period brings the tap controller to the run-test/idle state, wh ich is the starting point for jtag operations. 27.4.8 how to disable the module to disable the tms, tdi, and tdo pins the reset_n pin must be pulled low. 27.4.9 typical sequence assuming run-test/idle is the present state, a typical scenario for usin g the jtag interface follows. 27.4.9.1 scanning in jtag instruction at the tms input, apply the sequence 1, 1, 0, 0 at the rising edges of tck to enter the shift instruction register (shift-ir) state. while in this state, shift the 5 bits of the jtag instructions into the jtag instruction register from the tdi input at the rising edge of tck. during shifting, the jtag outputs status bits on tdo, refer to section 27.5 for a description of these. the tms input must be held low during input of the 4 lsbs in order to remain in the shift-ir state. the jtag instruction selects a partic ular data register as path between tdi and tdo and controls the circuitry surrounding th e selected data register. apply the tms sequence 1, 1, 0 to re-enter the run-test/idle state. the instruction is latched onto the parallel output from the shift register pat h in the update-ir state. the exit-ir, pause-ir, and exit2-ir states are only used for navigating the state machine. figure 27-6. scanning in jtag instruction 27.4.9.2 scanning in/out data at the tms input, apply the sequence 1, 0, 0 at the rising edges of tck to enter the shift data register (shift-dr) state. while in this state, upload the selected data register (selected by the present jtag instruction in the jtag instruction register) from the tdi input at the rising edge of tck. in order to remain in the shift-dr state, the tms input mu st be held low. while the data register is shifted in from the tdi pin, the parallel inputs to the data register captured in the capture-dr state is shifted out on the tdo pin. tck tap state tlr rti seldr selir capir shir ex1ir updir rti tms tdi instruction tdo impldefined
587 32059l?avr32?01/2012 at32uc3b apply the tms sequence 1, 1, 0 to re-enter the ru n-test/idle state. if the selected data register has a latched parallel-output, the latching take s place in the update-dr state. the exit-dr, pause-dr, and exit2-dr states are only used for navigating the state machine. as shown in the state diagram, the run-tes t/idle state need not be entered between selecting jtag instruction and using data registers. 27.4.10 boundary-scan the boundary-scan chain has the c apability of driving an d observing the logic levels on the digi- tal i/o pins, as well as the boundary between digi tal and analog logic for analog circuitry having off-chip connections. at system level, all ics having jtag capabilities ar e connected serially by the tdi/tdo signals to form a long shift register. an external controller sets up the devices to drive values at their output pins, and observe t he input values received from other devices. the controller compares the received data with the ex pected result. in this way, boundary-scan pro- vides a mechanism for testing interconnections and integrity of components on printed circuits boards by using the 4 tap signals only. the four ieee 1149.1 defined mandatory jtag in structions idcode, bypass, sample/pre- load, and extest can be used for testing the pr inted circuit board. initial scanning of the data register path will show th e id-code of the device, sinc e idcode is the default jtag instruction. it may be desirable to have the 32-b it avr device in reset during test mode. if not reset, inputs to the device may be determined by the scan operations, and the internal software may be in an undetermi ned state when exiting the test mode. if nee ded, the bypass instruction can be issued to make the shortest possible scan chain through the device. the device can be set in the reset state either by pulling the external resetn pi n low, or issuing the avr_reset instruction with appropriate setti ng of the reset data register. the extest instruction is used for sampling exte rnal pins and loading output pins with data. the data from the output latch will be driven out on the pins as soon as the extest instruction is loaded into the jtag ir-register. therefor e, the sample/preload sh ould also be used for setting initial values to the scan ring, to avoid damaging the board when issuing the extest instruction for the first time. sample/preload c an also be used for taking a snapshot of the external pins during normal operation of the part. when using the jtag interface for boundary-scan, the jtag tck clock is independent of the internal chip clock. the internal chip clock is not required to run during boundary-scan operations. note: for pins connected to 5v lines care should be taken to not drive the pins to a logic one using boundary-scan, as this will create a current fl owing from the 3,3v driver to the 5v pull-up on the line. optionally a series resistor can be added between the line and the pin to reduce the current. details about the boundary-scan chain can be fou nd in the bsdl file for the device. this can be found on the atmel website. 27.4.11 service access bus the avr32 architecture offers a common interf ace for access to on-chip debug, programming, and test functions. these are mapped on a common bus called t he service acce ss bus (sab), which is linked to the jtag through a bus master module, which also handles synchronization between the tck and sab clocks.
588 32059l?avr32?01/2012 at32uc3b for more information about the sab and a list of sab slaves see the service access bus chapter. 27.4.11.1 sab address mode the memory_sized_access instruction allows a sized read or write to any 36-bit address on the bus. memory_word_access is a shorthand instruction for 32-bit accesses to any 36-bit address, while the nexus_ access instruction is a nexus-compliant shorthand instruc- tion for accessing the 32-bit ocd registers in t he 7-bit address space reserved for these. these instructions require two passes through the shi ft-dr tap state: one for the address and control information, and one for data. 27.4.11.2 block transfer to increase the transfer rate, consecutive me mory accesses can be accomplished by the memory_block_access instruction, which only r equires a single pass through shift-dr for data transfer only. the address is automatically incremented according to the size of the last sab transfer. 27.4.11.3 canceling a sab access it is possible to abort an ongoing sab access by the cancel_access instruction, to avoid hanging the bus due to an extremely slow slave. 27.4.11.4 busy reporting as the time taken to perform an access may vary depending on system activity and current chip frequency, all the sab access jtag instructions can return a busy indicator. this indicates whether a delay needs to be inserted, or an operat ion needs to be repeated in order to be suc- cessful. if a new acce ss is requested while the sab is busy, the request is ignored. the sab becomes busy when: ? entering update-dr in the address phase of an y read operation, e.g., after scanning in a nexus_access address wit h the read bit set. ? entering update-dr in the data phase of any wr ite operation, e.g., after scanning in data for a nexus_access write. ? entering update-dr during a memory_block_access. ? entering update-dr after scanning in a counter value for sync. ? entering update-ir after scanning in a me mory_block_access if the previous access was a read and data was scanned after scanning the address. the sab becomes ready again when: ? a read or write operation completes. ? a sync countdown completed. ? a operation is cancelled by the cancel_access instruction. what to do if the busy bit is set: ? during shift-ir: the new instruction is selected, but the previous operation has not yet completed and will continue (unless the new instruction is cancel_access). you may continue shifting the same instruction until the busy bit clears, or start shifting data. if shifting data, you must be prepared that the data shift may also report busy. ? during shift-dr of an address: the new addres s is ignored. the sab stays in address mode, so no data must be shifted. repeat the address until the busy bit clears.
589 32059l?avr32?01/2012 at32uc3b ? during shift-dr of read data: the read data is invalid. the sab stays in data mode. repeat scanning until the busy bit clears. ? during shift-dr of write data: the write data is ignored. the sab stays in data mode. repeat scanning until the busy bit clears. 27.4.11.5 error reporting the service access bus may not be able to comp lete all accesses as requested. this may be because the address is invalid, the addressed area is read-only or cannot handle byte/halfword accesses, or because the chip is set in a pr otected mode where only limited accesses are allowed. the error bit is updated when an access complete s, and is cleared when a new access starts. what to do if the error bit is set: ? during shift-ir: the new instruction is selected. the last operation performed using the old instruction did not co mplete successfully. ? during shift-dr of an address: the previous operation failed. the new address is accepted. if the read bit is set, a read operation is started. ? during shift-dr of read data: the read operation failed, and the read data is invalid. ? during shift-dr of write data: the previous wr ite operation failed. the new data is accepted and a write operation started. this should only occur during block writes or stream writes. no error can occur between scanning a write address and the following write data. ? while polling with cancel_access: the previo us access was cancelled. it may or may not have actually completed. ? after power-up: the error bit is set after power up, but there has been no previous sab instruction so this error can be discarded. 27.4.11.6 protected reporting a protected status may be reported during shift-ir or shift-dr. this indicates that the security bit in the flash controller is set and that the chip is lo cked for access, according to section 27.5.1 . the protected state is reported when: ? the flash controller is under reset. this can be due to the avr_reset command or the reset_n line. ? the flash controller has not read the security bit from the flash yet (this will take a a few ms). happens after the flash controller reset has been released. ? the security bit in the flash controller is set. what to do if the protected bit is set: ? release all active avr_ reset domains, if any. ? release the reset_n line. ? wait a few ms for the security bit to clea r. it can be set tempor arily due to a reset. ? perform a chip_erase to clear the security bit. note : this will erase all t he contents of the non-volatile memory.
590 32059l?avr32?01/2012 at32uc3b 27.5 jtag instruction summary the implemented jtag instructions in the 32-bit avr are shown in the table below. 27.5.1 security restrictions when the security fuse in the flash is programmed, the following jtag instructions are restricted: ? nexus_access ? memory_word_access ? memory_block_access ? memory_sized_access for description of what memory locations rema in accessible, please refer to the sab address map. full access to these instructions is re-enabled when the security fuse is erased by the chip_erase jtag instruction. note that the security bit will read as programme d and block these instructions also if the flash controller is statically reset. table 27-7. jtag instruction summary instruction opcode instruction description 0x01 idcode select the 32-bit device identification register as data register. 0x02 sample_preload take a snapshot of external pin values without affecting system operation. 0x03 extest select boundary-scan chain as data regist er for testing circuitry external to the device. 0x04 intest select boundary-scan chain for internal testing of the device. 0x06 clamp bypass device through bypass register, while driving outputs from boundary- scan register. 0x0c avr_reset apply or remove a static reset to the device 0x0f chip_erase erase the device 0x10 nexus_access select the sab address and data registers as data register for the tap. the registers are accessed in nexus mode. 0x11 memory_word_access select the sab address and data registers as data register for the tap. 0x12 memory_block_access select the sab data register as data register for the tap. the address is auto-incremented. 0x13 cancel_access cancel an ongoing nexus or memory access. 0x14 memory_service select the sab address and data registers as data register for the tap. the registers are accessed in memory service mode. 0x15 memory_sized_access select the sab address and data registers as data register for the tap. 0x17 sync synchronization counter 0x1c halt halt the cpu for safe programming. 0x1f bypass bypass this device through the bypass register. others n/a acts as bypass
591 32059l?avr32?01/2012 at32uc3b other security mechanisms can also restrict these functions. if such mechanisms are present they are listed in the sab address map section. 27.5.1.1 notation table 27-9 on page 591 shows bit patterns to be shifted in a format like " peb01 ". each character corresponds to one bit, and eight bits are grouped together for re adability. the least significant- bit is always shifted first, and the most significant bit shifted last. the symbols used are shown in table 27-8 . in many cases, it is not required to shift all bits through the data register. bit patterns are shown using the full width of the shift register, but th e suggested or required bits are emphasized using bold text. i.e. given the pattern " aaaaaaar xxxxxxxx xxxxxxxx xxxxxxxx xx", the shift register is 34 bits, but the test or debug unit may choose to shift only 8 bits " aaaaaaar ". the following describes how to interpret the fields in the instruction description tables: table 27-8. symbol description symbol description 0 constant low value - always reads as zero. 1 constant high value - always reads as one. a an address bit - always scanned with the least significant bit first b a busy bit. reads as one if the sab wa s busy, or zero if it was not. see section 27.4.11.4 for details on how the busy reporting works. d a data bit - always scanned with the least significant bit first. e an error bit. reads as one if an error occurred, or zero if not. see section 27.4.11.5 for details on how the error reporting works. p the chip protected bit. some devices may be set in a protected state where access to chip internals are severely restricted. see the documentation for the specific device for details. on devices without this possibility, this bit always reads as zero. r a direction bit. set to one to request a read, set to zero to request a write. s a size bit. the size encoding is described where used. x a don?t care bit. any value can be shifted in, and output data should be ignored. table 27-9. instruction description instruction description ir input value shows the bit pattern to shift into ir in the shift-ir state in order to select this instruction. the pattern is show both in binary and in hexadecimal form for convenience. example: 10000 (0x10) ir output value shows the bit pattern shifted out of ir in the shift-ir state when this instruction is active. example: peb01
592 32059l?avr32?01/2012 at32uc3b 27.5.2 public jtag instructions the jtag standard defines a number of public jtag instructions. these instructions are described in the sections below. 27.5.2.1 idcode this instruction selects the 32 bi t device identification register (did) as data register. the did register consists of a version number, a device number, and the manufacturer code chosen by jedec. this is the default instruction after a jtag reset. details about the did register can be found in the module configuration se ction at the end of this chapter. starting in run-test/idle, the device identification register is accessed in the following way: 1. select the ir scan path. 2. in capture-ir: the ir output value is latched into the shift register. 3. in shift-ir: the instruction regi ster is shifted by the tck input. 4. return to run-test/idle. 5. select the dr scan path. 6. in capture-dr: the idcode value is latched into the shift register. 7. in shift-dr: the idcode scan chain is shifted by the tck input. 8. return to run-test/idle. 27.5.2.2 sample_preload this instruction takes a snap-shot of the input/ output pins without affect ing the system operation, and pre-loading the scan chain without updating the dr-latch. the boundary-scan chain is selected as data register. starting in run-test/idle, the device identification register is accessed in the following way: dr size shows the number of bits in the data regist er chain when this instruction is active. example: 34 bits dr input value shows which bit pattern to shift into the data register in the shift-dr state when this instruction is active. multiple such lines may exist, e.g., to distinguish between reads and writes. example: aaaaaaar xxxxxxxx xxxxxxxx xxxxxxxx xx dr output value shows the bit pattern shifted out of the data register in the shift-dr state when this instruction is active. multiple such lines may exist, e.g., to distinguish between reads and writes. example: xx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxeb table 27-9. instruction description (continued) instruction description table 27-10. idcode details instructions details ir input value 00001 (0x01) ir output value p0001 dr size 32 dr input value xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx dr output value device identification register
593 32059l?avr32?01/2012 at32uc3b 1. select the ir scan path. 2. in capture-ir: the ir output value is latched into the shift register. 3. in shift-ir: the instruction regi ster is shifted by the tck input. 4. return to run-test/idle. 5. select the dr scan path. 6. in capture-dr: the data on the external pins are sampled into the boundary-scan chain. 7. in shift-dr: the boundary-scan chain is shifted by the tck input. 8. return to run-test/idle. 27.5.2.3 extest this instruction selects the bounda ry-scan chain as data register for testing circuitry external to the 32-bit avr package. the contents of the latched outputs of the boundary-scan chain is driven out as soon as the jtag ir-registe r is loaded with th e extest instruction. starting in run-test/idle, the extest instruction is accessed the following way: 1. select the ir scan path. 2. in capture-ir: the ir output value is latched into the shift register. 3. in shift-ir: the instruction regi ster is shifted by the tck input. 4. in update-ir: the data from the boundary-scan chain is applied to the output pins. 5. return to run-test/idle. 6. select the dr scan path. 7. in capture-dr: the data on the external pins is sampled into the boundary-scan chain. 8. in shift-dr: the boundary-scan chain is shifted by the tck input. 9. in update-dr: the data from the scan chain is applied to the output pins. 10. return to run-test/idle. table 27-11. sample_preload details instructions details ir input value 00010 (0x02) ir output value p0001 dr size depending on boundary-scan chain, see bsdl-file. dr input value depending on boundary-scan chain, see bsdl-file. dr output value depending on boundary-scan chain, see bsdl-file. table 27-12. extest details instructions details ir input value 00011 (0x03) ir output value p0001 dr size depending on boundary-scan chain, see bsdl-file. dr input value depending on boundary-scan chain, see bsdl-file. dr output value depending on boundary-scan chain, see bsdl-file.
594 32059l?avr32?01/2012 at32uc3b 27.5.2.4 intest this instruction selects the boundary-scan chain as data register for testing internal logic in the device. the logic inputs are determined by the boundary-scan chain, and the logic outputs are captured by the boundary-scan chain. the device output pins are driven from the boundary-scan chain. starting in run-test/idle, the intest instruction is access ed the following way: 1. select the ir scan path. 2. in capture-ir: the ir output value is latched into the shift register. 3. in shift-ir: the instruction regi ster is shifted by the tck input. 4. in update-ir: the data from the boundary-scan chain is applied to the internal logic inputs. 5. return to run-test/idle. 6. select the dr scan path. 7. in capture-dr: the data on the internal logic is sampled into the boundary-scan chain. 8. in shift-dr: the boundary-scan chain is shifted by the tck input. 9. in update-dr: the data from the boundary-scan chain is applied to internal logic inputs. 10. return to run-test/idle. 27.5.2.5 clamp this instruction selects the bypass register as data register. the device output pins are driven from the boundary-scan chain. starting in run-test/idle, the clamp instruction is acce ssed the following way: 1. select the ir scan path. 2. in capture-ir: the ir output value is latched into the shift register. 3. in shift-ir: the instruction regi ster is shifted by the tck input. 4. in update-ir: the data from the boundary-scan chain is applied to the output pins. 5. return to run-test/idle. 6. select the dr scan path. 7. in capture-dr: a logic ?0? is loaded into the bypass register. 8. in shift-dr: data is scanned from td i to tdo through the bypass register. table 27-13. intest details instructions details ir input value 00100 (0x04) ir output value p0001 dr size depending on boundary-scan chain, see bsdl-file. dr input value depending on boundary-scan chain, see bsdl-file. dr output value depending on boundary-scan chain, see bsdl-file.
595 32059l?avr32?01/2012 at32uc3b 9. return to run-test/idle. 27.5.2.6 bypass this instruction selects the 1-bit bypass register as data register. starting in run-test/idle, the clamp instruction is acce ssed the following way: 1. select the ir scan path. 2. in capture-ir: the ir output value is latched into the shift register. 3. in shift-ir: the instruction regi ster is shifted by the tck input. 4. return to run-test/idle. 5. select the dr scan path. 6. in capture-dr: a logic ?0? is loaded into the bypass register. 7. in shift-dr: data is scanned from td i to tdo through the bypass register. 8. return to run-test/idle. 27.5.3 private jtag instructions the 32-bit avr defines a number of private jt ag instructions, not def ined by the jtag stan- dard. each instruction is br iefly described in text, with det ails following in table form. 27.5.3.1 nexus_access this instruction allows nexus- compliant access to the on-chip debug registers through the sab. the 7-bit register index, a read/write control bit, and the 32-bit data is accessed through the jtag port. the data register is alternately interpreted by the sab as an address register and a data regis- ter. the sab starts in addre ss mode after the nexus_access instruction is selected, and toggles between address and data mode each time a data scan completes with the busy bit cleared. note : the polarity of the direction bit is inverse of the nexus standard. table 27-14. clamp details instructions details ir input value 00110 (0x06) ir output value p0001 dr size 1 dr input value x dr output value x table 27-15. bypass details instructions details ir input value 11111 (0x1f) ir output value p0001 dr size 1 dr input value x dr output value x
596 32059l?avr32?01/2012 at32uc3b starting in run-test/idle, ocd regist ers are accessed in the following way: 1. select the ir scan path. 2. in capture-ir: the ir output value is latched into the shift register. 3. in shift-ir: the instruction regi ster is shifted by the tck input. 4. return to run-test/idle. 5. select the dr scan path. 6. in shift-dr: scan in the direction bit (1=read, 0=write) and the 7-bit address for the ocd register. 7. go to update-dr and re-enter select-dr scan. 8. in shift-dr: for a read operation, scan ou t the contents of the addressed register. for a write operation, scan in the new contents of the register. 9. return to run-test/idle. for any operation, the full 7 bits of the addres s must be provided. for write operations, 32 data bits must be provided, or the result will be undefined. for read ope rations, shifting may be termi- nated once the required number of bits have been acquired. 27.5.3.2 memory_service this instruction allows access to registers in an optional memory service unit. the 7-bit register index, a read/write control bit, and the 32-b it data is accessed through the jtag port. the data register is alternately interpreted by the sab as an address register and a data regis- ter. the sab starts in addres s mode after the memory_service instruction is selected, and toggles between address and data mode each time a data scan completes with the busy bit cleared. starting in run-test/idle, me mory service registers are accessed in the following way: 1. select the ir scan path. 2. in capture-ir: the ir output value is latched into the shift register. 3. in shift-ir: the instruction regi ster is shifted by the tck input. 4. return to run-test/idle. 5. select the dr scan path. 6. in shift-dr: scan in the direction bit (1=read, 0=write) and the 7-bit address for the memory service register. table 27-16. nexus_access details instructions details ir input value 10000 (0x10) ir output value peb01 dr size 34 bits dr input value (address phase) aaaaaaar xxxxxxxx xxxxxxxx xxxxxxxx xx dr input value (data read phase) xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xx dr input value (data write phase) dddddddd dddddddd dddddddd dddddddd xx dr output value (address phase) xx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxeb dr output value (data read phase) eb dddddddd dddddddd dddddddd dddddddd dr output value (data write phase) xx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxeb
597 32059l?avr32?01/2012 at32uc3b 7. go to update-dr and re-enter select-dr scan. 8. in shift-dr: for a read operation, scan ou t the contents of the addressed register. for a write operation, scan in the new contents of the register. 9. return to run-test/idle. for any operation, the full 7 bits of the addres s must be provided. for write operations, 32 data bits must be provided, or the result will be undefined. for read ope rations, shifting may be termi- nated once the required number of bits have been acquired. 27.5.3.3 memory_sized_access this instruction allows access to the entire service access bus data area. data is accessed through a 36-bit byte index, a 2-bit size, a direction bit, and 8, 16, or 32 bits of data. not all units mapped on the sab bus may support all sizes of accesses, e.g., some may only support word accesses. the data register is alternately interpreted by the sab as an address register and a data regis- ter. the sab starts in address mode after the memory_sized_access instruction is selected, and toggles between address and data mode each time a data scan completes with the busy bit cleared. table 27-17. memory_service details instructions details ir input value 10100 (0x14) ir output value peb01 dr size 34 bits dr input value (address phase) aaaaaaar xxxxxxxx xxxxxxxx xxxxxxxx xx dr input value (data read phase) xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xx dr input value (data write phase) dddddddd dddddddd dddddddd dddddddd xx dr output value (address phase) xx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxeb dr output value (data read phase) eb dddddddd dddddddd dddddddd dddddddd dr output value (data write phase) xx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxeb
598 32059l?avr32?01/2012 at32uc3b the size field is encoded as i table 27-18 . starting in run-test/idle, sab data is accessed in the following way: 1. select the ir scan path. 2. in capture-ir: the ir output value is latched into the shift register. 3. in shift-ir: the instruction regi ster is shifted by the tck input. 4. return to run-test/idle. 5. select the dr scan path. 6. in shift-dr: scan in the direction bit (1=read, 0=write), 2-bit access size, and the 36-bit address of the data to access. 7. go to update-dr and re-enter select-dr scan. 8. in shift-dr: for a read operation, scan out the contents of the addressed area. for a write operation, scan in the new contents of the area. 9. return to run-test/idle. for any operation, the full 36 bits of the address must be provided. for write operations, 32 data bits must be provided, or the result will be undefined. for read ope rations, shifting may be termi- nated once the required number of bits have been acquired. table 27-18. size field semantics size field value access size data alignment 00 byte (8 bits) address modulo 4 : data alignment 0: dddddddd xxxxxxxx xxxxxxxx xxxxxxxx 1: xxxxxxxx dddddddd xxxxxxxx xxxxxxxx 2: xxxxxxxx xxxxxxxx dddddddd xxxxxxxx 3: xxxxxxxx xxxxxxxx xxxxxxxx dddddddd 01 halfword (16 bits) address modulo 4 : data alignment 0: dddddddd dddddddd xxxxxxxx xxxxxxxx 1: not allowed 2: xxxxxxxx xxxxxxxx dddddddd dddddddd 3: not allowed 10 word (32 bits) address modulo 4 : data alignment 0: dddddddd dddddddd dddddddd dddddddd 1: not allowed 2: not allowed 3: not allowed 11 reserved n/a table 27-19. memory_sized_access details instructions details ir input value 10101 (0x15) ir output value peb01 dr size 39 bits dr input value (address phase) aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaassr dr input value (data read phase) xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxx dr input value (data write phase) dddddddd dddddddd dddddddd dddddddd xxxxxxx
599 32059l?avr32?01/2012 at32uc3b 27.5.3.4 memory_word_access this instruction allows access to the entire service access bus data area. data is accessed through the 34 msb of the sab addr ess, a direction bit, and 32 bits of data. this instruction is identical to memory_sized_access except that it always does word sized accesses. the size field is implied, and the two lowest address bits are removed and not scanned in . note: this instruction was previously known as memory_access, and is provided for back- wards compatibility. the data register is alternately interpreted by the sab as an address register and a data regis- ter. the sab starts in address mode afte r the memory_word_a ccess instruction is selected, and toggles between address and data mode each time a data scan completes with the busy bit cleared. starting in run-test/idle, sab data is accessed in the following way: 1. select the ir scan path. 2. in capture-ir: the ir output value is latched into the shift register. 3. in shift-ir: the instruction regi ster is shifted by the tck input. 4. return to run-test/idle. 5. select the dr scan path. 6. in shift-dr: scan in the direction bit (1=read, 0=write) and the 34-bit address of the data to access. 7. go to update-dr and re-enter select-dr scan. 8. in shift-dr: for a read operation, scan out the contents of the addressed area. for a write operation, scan in the new contents of the area. 9. return to run-test/idle. for any operation, the full 34 bits of the address must be provided. for write operations, 32 data bits must be provided, or the result will be undefined. for read ope rations, shifting may be termi- nated once the required number of bits have been acquired. dr output value (address phase) xxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxeb dr output value (d ata read phase) xxxxxeb dddddddd dddddddd dddddddd dddddddd dr output value (data write phase) xxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxeb table 27-19. memory_sized_access details (continued) instructions details table 27-20. memory_word_access details instructions details ir input value 10001 (0x11) ir output value peb01 dr size 35 bits dr input value (address phase) aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aar dr input value (data read phase) xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxx dr input value (data write phase) dddddddd dddddddd dddddddd dddddddd xxx
600 32059l?avr32?01/2012 at32uc3b 27.5.3.5 memory_block_access this instruction allows ac cess to the entire sab data area. up to 32 bits of data is accessed at a time, while the address is sequentially incr emented from the previously used address. in this mode, the sab address, size, and access direction is not provided with each access. instead, the previous address is auto-incremente d depending on the specified size and the pre- vious operation repeated. the address must be set up in advance with memory_size_access or memory_word_acce ss. it is allowed, but not required, to shift data after shifting the address. this instruction is primarily intended to speed up large quantities of sequential word accesses. it is possible to use it also for byte and halfword accesses, but t he overhead in this is case much larger as 32 bits must still be shifted for each access. the following sequence should be used: 1. use the memory_size_access or memory _word_access to read or write the first location. 2. return to run-test/idle. 3. select the ir scan path. 4. in capture-ir: the ir output value is latched into the shift register. 5. in shift-ir: the instruction regi ster is shifted by the tck input. 6. return to run-test/idle. 7. select the dr scan path. the address will now have incremented by 1, 2, or 4 (corre- sponding to the next byte, halfword, or word location). 8. in shift-dr: for a read operation, scan out the contents of the ne xt addressed location. for a write operation, scan in the new co ntents of the next addressed location. 9. go to update-dr. 10. if the block access is not co mplete, return to select-dr scan and repeat the access. 11. if the block access is comple te, return to run-test/idle. for write operations, 32 data bits must be pr ovided, or the result will be undefined. for read operations, shifting may be terminated once the required number of bits have been acquired. dr output value (address phase) xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xeb dr output value (data read phase) xeb dddddddd dddddddd dddddddd dddddddd dr output value (data write phase) xxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxeb table 27-20. memory_word_access details (continued) instructions details table 27-21. memory_block_access details instructions details ir input value 10010 (0x12) ir output value peb01 dr size 34 bits dr input value (data read phase) xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xx
601 32059l?avr32?01/2012 at32uc3b the overhead using block word access is 4 cycles per 32 bits of data, resulting in an 88% trans- fer efficiency, or 2.1 mbytes per second with a 20 mhz tck frequency. 27.5.3.6 cancel_access if a very slow memory location is accessed du ring a sab memory access, it could take a very long time until the busy bit is cleared, and the sab becomes ready for the next operation. the cancel_access instruction pr ovides a possibility to abort an ongoing transfer and report a timeout to the jtag master. when the cancel_access instruction is select ed, the current access will be terminated as soon as possible. there are no guarantees about how long this will take, as the hardware may not always be able to cancel t he access immediately. the sab is ready to respond to a new command when the busy bit clears. starting in run-test/idl e, cancel_access is acce ssed in the following way: 1. select the ir scan path. 2. in capture-ir: the ir output value is latched into the shift register. 3. in shift-ir: the instruction regi ster is shifted by the tck input. 4. return to run-test/idle. 27.5.3.7 sync this instruction allows external debuggers and testers to measure the ratio between the external jtag clock and the internal system clock. the sync data register is a 16-bit counter that counts down to zero using the internal system cl ock. the busy bit stays high until the counter reaches zero. starting in run-test/idle, sync inst ruction is used in the following way: 1. select the ir scan path. 2. in capture-ir: the ir output value is latched into the shift register. 3. in shift-ir: the instruction regi ster is shifted by the tck input. 4. return to run-test/idle. 5. select the dr scan path. dr input value (data write phase) dddddddd dddddddd dddddddd dddddddd xx dr output value (data read phase) eb dddddddd dddddddd dddddddd dddddddd dr output value (data write phase) xx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxeb table 27-21. memory_block_access details (continued) instructions details table 27-22. cancel_access details instructions details ir input value 10011 (0x13) ir output value peb01 dr size 1 dr input value x dr output value 0
602 32059l?avr32?01/2012 at32uc3b 6. scan in an 16-bit counter value. 7. go to update-dr and re-enter select-dr scan. 8. in shift-dr: scan out the busy bit, and until the busy bit clears goto 7. 9. calculate an approximation to the internal clock speed using the elapsed time and the counter value. 10. return to run-test/idle. the full 16-bit counter value must be provided when starting the synch operation, or the result will be undefined. when r eading status, shifting may be term inated once the required number of bits have been acquired. 27.5.3.8 avr_reset this instruction allows a debugger or tester to di rectly control se parate reset doma ins inside the chip. the shift register contains one bit for each controllable reset domain. setting a bit to one resets that domain and holds it in reset. setting a bit to zero releases the reset for that domain. the avr_reset instruction can be used in the following way: 1. select the ir scan path. 2. in capture-ir: the ir output value is latched into the shift register. 3. in shift-ir: the instruction regi ster is shifted by the tck input. 4. return to run-test/idle. 5. select the dr scan path. 6. in shift-dr: scan in the value correspond ing to the reset domains the jtag master wants to reset into the data register. 7. return to run-test/idle. 8. stay in run test idle for at least 10 tck clock cycles to let the reset propagate to the system. see the device specific document ation for the number of rese t domains, and what these domains are. for any operation, all bits must be provided or th e result will be undefined. table 27-23. sync_access details instructions details ir input value 10111 (0x17) ir output value peb01 dr size 16 bits dr input value dddddddd dddddddd dr output value xxxxxxxx xxxxxxeb table 27-24. avr_reset details instructions details ir input value 01100 (0x0c) ir output value p0001
603 32059l?avr32?01/2012 at32uc3b 27.5.3.9 chip_erase this instruction allows a programmer to completely erase all nonvolatile memories in a chip. this will also clear any secu rity bits that are set, so t he device can be accessed normally. in devices without non-volatile memories this instruction does nothing, and appears to complete immediately. the erasing of non-volatile memo ries starts as soon as the chi p_erase instruction is selected. the chip_erase instruction select s a 1 bit bypass data register. a chip erase operation should be performed as: 1. reset the system and stop the cpu from executing. 2. select the ir scan path. 3. in capture-ir: the ir output value is latched into the shift register. 4. in shift-ir: the instruction regi ster is shifted by the tck input. 5. check the busy bit that was scanned out during shift-ir. if the busy bit was set goto 2. 6. return to run-test/idle. 27.5.3.10 halt this instruction allows a programmer to easily stop the cpu to ensure that it does not execute invalid code during programming. this instruction selects a 1-bit halt register. setting this bit to one resets the device and halts the cpu. setting this bit to zero resets the device and releases the cpu to run normally. the value shifted out from the data register is one if the cpu is halted. the halt instruction can be used in the following way: 1. select the ir scan path. 2. in capture-ir: the ir output value is latched into the shift register. 3. in shift-ir: the instruction regi ster is shifted by the tck input. 4. return to run-test/idle. 5. select the dr scan path. dr size device specific. dr input value device specific. dr output value device specific. table 27-24. avr_reset details (continued) instructions details table 27-25. chip_erase details instructions details ir input value 01111 (0x0f) ir output value p0b01 where b is the busy bit. dr size 1 bit dr input value x dr output value 0
604 32059l?avr32?01/2012 at32uc3b 6. in shift-dr: scan in the value 1 to ha lt the cpu, 0 to start cpu execution. 7. return to run-test/idle. table 27-26. halt details instructions details ir input value 11100 (0x1c) ir output value p0001 dr size 1 bit dr input value d dr output value d
605 32059l?avr32?01/2012 at32uc3b 27.6 jtag data registers the following device specific registers can be selected as jtag scan chain depending on the instruction loaded in the jtag in struction register. additional re gisters exist, but are implicitly described in the functional descripti on of the relevant instructions. 27.6.1 device identification register the device identification register contains a unique identifier for each product. the register is selected by the idcode instruction, which is the default instruction after a jtag reset. 27.6.1.1 device specific id codes the different device configurations have different jtag id codes, as shown in table 27-27 . note that if the flash co ntroller is statically rese t, the id code will be undefined . 27.6.2 reset register the reset register is selected by the avr_reset instruction and co ntains one bit for each reset domain in the device. se tting each bit to one will keep that domain reset until the bit is cleared. msb lsb bit 31 28 27 12 11 1 0 device id revision part number manufacturer id 1 4 bits 16 bits 11 bits 1 bit revision this is a 4 bit number identifying the revision of the component. rev a = 0x0, b = 0x1, etc. part number the part number is a 16 bit code identifying the component. manufacturer id the manufacturer id is a 11 bi t code identifying the manufacturer. the jtag manufacturer id for atmel is 0x01f. table 27-27. device and jtag id device name jtag id code (r is the revision number) at32uc3b0512 0xr205003f at32uc3b1512 0xr205203f at32uc3b0256 0xr1ee403f at32uc3b1256 0xr1ee503f at32uc3b0128 0xr1ee603f at32uc3b1128 0xr1ee903f at32uc3b064 0xr1eea03f at32uc3b164 0xr1eeb03f lsb bit 43210 device id ocd app reserved reserved cpu
606 32059l?avr32?01/2012 at32uc3b note: this register is primarily intended for com patibility with other 32- bit avr devices. certain operations may not function correc tly when parts of the system are reset. it is generally recom- mended to only write 0x11111 or 0x00000 to thes e bits to ensure no unintended side effects occur. 27.6.3 boundary-scan chain the boundary-scan chain has the ca pability of driving an d observing the logic levels on the dig- ital i/o pins, as well as driving and observing the logic levels between the digital i/o pins and the internal logic. typically, output value, output enable, and input data are all available in the boundary scan chain. the boundary scan chain is described in the bdsl (boundary scan description language) file available at the atmel web site. 27.7 sab address map the service access bus (sab) gives the user ac cess to the internal address space and other features through a 36 bits address space. the 4 msbs identify the slave number, while the 32 lsbs are decoded within the slave?s addres s space. the sab slaves are shown in table 27-28 . cpu cpu app hsb and pb buses ocd on-chip debug logic and registers rserved no effect table 27-28. sab slaves, addresses and descriptions. slave address [35:32] description unallocated 0x0 intentionally unallocated ocd 0x1 ocd registers hsb 0x4 hsb memory space, as seen by the cpu hsb 0x5 alternative mapping for hsb sp ace, for compatibility with other 32-bit avr devices. memory service unit 0x6 memory service unit registers reserved other unused
607 32059l?avr32?01/2012 at32uc3b 28. electrical characteristics 28.1 absolute maximum ratings* operating temperature.................................... -40c to +85c *notice: stresses beyond those listed under ?absolute maximum ratings? may cause permanent dam- age to the device. this is a stress rating only and functional operation of the device at these or other conditions beyond those indicated in the operational sections of this specification is not implied. exposure to absolute maximum rating conditions for extended periods may affect device reliability. storage temperature ..................................... -60c to +150c voltage on gpio pins with respect to ground for tck, reset_n, pa03, pa04, pa05, pa06, pa07, pa08, pa11, pa12, pa18, pa19, pa28, pa29, pa30, pa31 ................................................. -0.3 to 3.6v voltage on gpio pins with respect to ground exc ept for tck, reset_n, pa03, pa04, pa05, pa06, pa07, pa08, pa11, pa12, pa18, pa19, pa28, pa29, pa30, pa31....................................... -0.3 to 5.5v maximum operating voltage (vddcore, vddpll) ..... 1.95v maximum operating voltage (vddio,vddin,vddana) . 3.6v total dc output current on all i/o pin for 48-pin package ....................................................... 200 ma for 64-pin package ....................................................... 265 ma
608 32059l?avr32?01/2012 at32uc3b 28.2 dc characteristics the following characteristics are applicable to the operating temperature range: t a = -40c to 85c, unless otherwise spec- ified and are certified for a junction temperature up to t j = 100c. table 28-1. dc characteristics symbol parameter conditions min. typ. max. unit v vddcore dc supply core 1.65 1.95 v v vddpll dc supply pll 1.65 1.95 v v vddio dc supply peripheral i/os 3.0 3.6 v v il input low-level voltage -0.3 +0.8 v v ih input high-level voltage at32uc3b064 at32uc3b0128 at32uc3b0256 at32uc3b164 at32uc3b1128 at32uc3b1256 all i/o pins except tck, reset_n, pa03, pa04, pa05, pa06, pa07, pa08, pa11, pa12, pa18, pa19, pa28, pa29, pa30, pa31 2.0 5.5 v tck, reset_n, pa03, pa04, pa05, pa06, pa07, pa08, pa11, pa12, pa18, pa19, pa28, pa29, pa30, pa31 2.0 3.6 v at32uc3b0512 at32uc3b1512 all i/o pins except tck, reset_n, pa03, pa04, pa05, pa06, pa07, pa08, pa11, pa12, pa18, pa19, pa28, pa29, pa30, pa31 2.0 5.5 v tck, reset_n 2.5 3.6 v pa03, pa04, pa05, pa06, pa07, pa08, pa11, pa12, pa18, pa19, pa28, pa29, pa30, pa31 2.0 3.6 v v ol output low-level voltage i ol = -4ma for all i/o except pa20, pa21, pa22, pa23 0.4 v i ol = -8ma for pa20, pa21, pa22, pa23 0.4 v v oh output high-level voltage i ol = -4ma for all i/o except pa20, pa21, pa22, pa23 v vddio -0.4 v i ol = -8ma for pa20, pa21, pa22, pa23 v vddio -0.4 v i ol output low-level current all i/o pins except pa20, pa21, pa22, pa23 -4 ma pa20, pa21, pa22, pa23 -8 ma i oh output high-level current all i/o pins except for pa20, pa21, pa22, pa23 4ma pa20, pa21, pa22, pa23 8 ma i leak input leakage current pullup resistors disabled 1 a
609 32059l?avr32?01/2012 at32uc3b c in input capacitance qfp64 7 pf qfp48 7 pf qfn64 7 pf qfn48 7 pf r pullup pull-up resistance at32uc3b064 at32uc3b0128 at32uc3b0256 at32uc3b164 at32uc3b1128 at32uc3b1256 all i/o pins except reset_n, tck, tdi, tms pins 13 19 25 k reset_n pin, tck, tdi, tms pins 51225k at32uc3b0512 at32uc3b1512 all i/o pins except pa20, pa21, pa22, pa23, reset_n, tck, tdi, tms pins 10 15 20 k pa20, pa21, pa22, pa23 5 7.5 12 k reset_n pin, tck, tdi, tms pins 51025k i sc static current at32uc3b064 at32uc3b0128 at32uc3b0256 at32uc3b164 at32uc3b1128 at32uc3b1256 on v vddcore = 1.8v, device in static mode t a = 25c 6a all inputs driven including jtag; reset_n=1 t a = 85c 42.5 a at32uc3b0512 at32uc3b1512 on v vddcore = 1.8v, device in static mode t a = 25c 7.5 a all inputs driven including jtag; reset_n=1 t a = 85c 39 a table 28-1. dc characteristics symbol parameter conditions min. typ. max. unit
610 32059l?avr32?01/2012 at32uc3b 28.3 regulator characteristics 28.4 analog characteristics 28.4.1 adc reference 28.4.2 bod table 28-6 describes the values of the bodlevel field in the flash fgpfr register. table 28-2. electrical characteristics symbol parameter conditions min. typ. max. unit v vddin supply voltage (input) 3 3.3 3.6 v v vddout supply voltage (output) 1.70 1.8 1.85 v i out maximum dc output current v vddin = 3.3v 100 ma i scr static current of internal regulator low power mode (stop, deep stop or static) at t a = 25c 10 a table 28-3. decoupling requirements symbol parameter conditi ons typ. technology unit c in1 input regulator capacitor 1 1 npo nf c in2 input regulator capacitor 2 4.7 x7r f c out1 output regulator capacitor 1 470 npo pf c out2 output regulator capacitor 2 2.2 x7r f table 28-4. electrical characteristics symbol parameter conditions min. typ. max. unit v advref analog voltage reference (input) 2.6 3.6 v table 28-5. decoupling requirements symbol parameter conditi ons typ. technology unit c vref1 voltage reference capacitor 1 10 npo nf c vref2 voltage reference capacitor 2 1 npo uf table 28-6. bod level values symbol parameter value conditions min. typ. max. unit bodlevel 00 0000b 1.44 v 01 0111b 1.52 v 01 1111b 1.61 v 10 0111b 1.71 v
611 32059l?avr32?01/2012 at32uc3b 28.4.3 reset sequence table 28-7. bod timing symbol parameter conditions min. typ. max. unit t bod minimum time with vddcore < vbod to detect power failure falling vddcore from 1.8v to 1.1v 300 800 ns table 28-8. electrical characteristics symbol parameter conditions min. typ. max. unit v ddrr vddcore rise rate to ensure power- on-reset 2.5 v/ms v ddfr vddcore fall rate to ensure power- on-reset 0.01 400 v/ms v por+ rising threshold voltage: voltage up to which device is kept under reset by por on rising vddcore rising vddcore: v restart -> v por+ 1.4 1.55 1.65 v v por- falling threshold voltage: voltage when por resets device on falling vddcore falling vddcore: 1.8v -> v por+ 1.2 1.3 1.4 v v restart on falling vddcore, voltage must go down to this value before supply can rise again to ensure reset signal is released at v por+ falling vddcore: 1.8v -> v restart -0.1 0.5 v t por minimum time with vddcore < v por- falling vddcore: 1.8v -> 1.1v 15 s t rst time for reset signal to be propagated to system 200 400 s t ssu1 time for cold system startup: time for cpu to fetch its first instruction (rcosc not calibrated) 480 960 s t ssu2 time for hot system startup: time for cpu to fetch its first instruction (rcosc calibrated) 420 s
612 32059l?avr32?01/2012 at32uc3b figure 28-1. mcu cold start-up r eset_n tied to vddin figure 28-2. mcu cold start-up rese t_n externally driven figure 28-3. mcu hot start-up in dual supply configuration, the power up sequence must be carefully managed to ensure a safe startup of the device in all conditions. the power up sequence must ensure that the inte rnal logic is safely powered when the internal reset (power on reset) is released and that the internal flash logic is safely powered when the cpu fetch the first instructions. v por+ vddcore internal mcu reset t ssu1 internal por reset v por- t por t rst reset_n v restart v por+ vddcore internal mcu reset t ssu1 internal por reset v por- t por t rst reset_n v restart vddcore internal mcu reset t ssu2 reset_n bod reset wdt reset
613 32059l?avr32?01/2012 at32uc3b therefore vddcore rise rate (v ddrr) must be equal or superi or to 2.5v/ms and vddio must reach vddio mini value before 500 us (< trst + tssu1) after vddcore has reached v por+ min value. figure 28-4. dual supply configuration 28.4.4 reset_n characteristics v d d r r 2 . 5 v / m s m i n i m u m vpor+ min vddio min <500us vddio vddcore internal por (active low ) trst tssu1 first instruction fetched in flash table 28-9. reset_n waveform parameters symbol parameter conditions min. typ. max. unit t reset reset_n minimum pulse width 10 ns
614 32059l?avr32?01/2012 at32uc3b 28.5 power consumption the values in table 28-10 , table 28-11 on page 615 and table 28-12 on page 616 are mea- sured values of power consumption with operating conditions as follows: ?v ddio = v ddana = 3.3v ?v ddcore = v ddpll = 1.8v ?t a = 25 c, t a = 85 c ?i/os are configured in input, pull-up enabled. figure 28-5. measurement setup the following tables represent the power c onsumption measured on the power supplies. internal voltage regulator amp0 amp1 vddana vddio vddin vddout vddcore vddpll
615 32059l?avr32?01/2012 at32uc3b 28.5.1 power consumtion for different sleep modes notes: 1. core frequency is generated from xin0 using the pll so that 140 mhz < f pll0 < 160 mhz and 10 mhz < f xin0 < 12 mhz. table 28-10. power consumption for different sleep modes for at32uc3b064, at32uc3b0128, at32uc3b0256, at32uc3b164, at32uc3b1128, at32uc3b1256 mode conditions typ. unit active - cpu running a recursive fibonacci algorithm from flash and clocked from pll0 at f mhz. - voltage regulator is on. - xin0: external clock. xin1 stopped. xin32 stopped. - all peripheral clocks activated with a division by 8. - gpios are inactive with internal pull- up, jtag unconnected with external pull- up and input pins are connected to gnd 0.3xf(mhz)+0.443 ma/mhz same conditions at 60 mhz 18.5 ma idle see active mode conditions 0.117xf(mhz)+0.28 ma/mhz same conditions at 60 mhz 7.3 ma frozen see active mode conditions 0.058xf(mhz)+0.115 ma/mhz same conditions at 60 mhz 3.6 ma standby see active mode conditions 0.042xf(mhz)+0.115 ma/mhz same conditions at 60 mhz 2.7 ma stop - cpu running in sleep mode - xin0, xin1 and xin32 are stopped. - all peripheral clocks are desactived. - gpios are inactive with internal pull- up, jtag unconnected with external pull- up and input pins are connected to gnd. 37.8 a deepstop see stop mode conditions 24.9 a static see stop mode conditions voltage regulator on 13.9 a voltage regulator off 8.9 a table 28-11. power consumption for different sleep modes for at32uc3b0512, at32uc3b1512 mode conditions typ. unit active - cpu running a recursive fibonacci algorithm from flash and clocked from pll0 at f mhz. - voltage regulator is on. - xin0: external clock. xin1 stopped. xin32 stopped. - all peripheral clocks activated with a division by 8. - gpios are inactive with internal pull- up, jtag unconnected with external pull- up and input pins are connected to gnd 0.359xf(mhz)+1.53 ma/mhz same conditions at 60 mhz 24 ma idle see active mode conditions 0.146xf(mhz)+0.291 ma/mhz same conditions at 60 mhz 9 ma
616 32059l?avr32?01/2012 at32uc3b notes: 1. core frequency is generated from xin0 using the pll so that 140 mhz < f pll0 < 160 mhz and 10 mhz < f xin0 < 12 mhz. frozen see active mode conditions 0.0723xf(mhz)+0.15 6 ma/mhz same conditions at 60 mhz 4.5 ma standby see active mode conditions 0.0537xf(mhz)+0.16 6 ma/mhz same conditions at 60 mhz 3.4 ma stop - cpu running in sleep mode - xin0, xin1 and xin32 are stopped. - all peripheral clocks are desactived. - gpios are inactive with internal pull- up, jtag unconnected with external pull- up and input pins are connected to gnd. 62 a deepstop see stop mode conditions 30 a static see stop mode conditions voltage regulator on 15.5 a voltage regulator off 7.5 table 28-11. power consumption for different sleep modes for at32uc3b0512, at32uc3b1512 mode conditions typ. unit table 28-12. peripheral interface power consumption in active mode peripheral conditions consumption unit intc at32uc3b064 at32uc3b0128 at32uc3b0256 at32uc3b164 at32uc3b1128 at32uc3b1256 at32uc3b0512 at32uc3b1512 20 a/mhz gpio 16 pdca 12 usart 14 usb 23 adc 8 twi 7 pwm 18 spi 8 ssc 11 tc 11 abdac at32uc3b0512 at32uc3b1512 6
617 32059l?avr32?01/2012 at32uc3b 28.6 system clock characteristics these parameters are given in the following conditions: ?v ddcore = 1.8v ? ambient temperature = 25c 28.6.1 cpu/hsb cloc k characteristics 28.6.2 pba clock characteristics 28.6.3 pbb clock characteristics table 28-13. core clock waveform parameters symbol parameter conditions min. typ. max. unit 1/(t cpcpu ) cpu clock frequency 60 mhz t cpcpu cpu clock period 16.6 ns table 28-14. pba clock waveform parameters symbol parameter conditions min. typ. max. unit 1/(t cppba ) pba clock frequency 60 mhz t cppba pba clock period 16.6 ns table 28-15. pbb clock waveform parameters symbol parameter conditions min. typ. max. unit 1/(t cppbb ) pbb clock frequency 60 mhz t cppbb pbb clock period 16.6 ns
618 32059l?avr32?01/2012 at32uc3b 28.7 oscillator characteristics the following characteristics are applicabl e to the operating temperature range: t a = -40c to 85c and worst case of power supply, unless otherwise specified. 28.7.1 slow clock rc oscillator 28.7.2 32 khz oscillator note: 1. c l is the equivalent load capacitance. table 28-16. rc oscillator frequency symbol parameter conditions min. typ. max. unit f rc rc oscillator frequency calibration point: t a = 85c 115.2 116 khz t a = 25c 112 khz t a = -40c 105 108 khz table 28-17. 32 khz oscillator characteristics symbol parameter conditions min. typ. max. unit 1/(t cp32khz ) oscillator frequency external clock on xin32 30 mhz crystal 32 768 hz c l equivalent load capacitance 6 12.5 pf esr crystal equivalent series resistance 100 k t st startup time c l = 6pf (1) c l = 12.5pf (1) 600 1200 ms t ch xin32 clock high half-period 0.4 t cp 0.6 t cp t cl xin32 clock low half-period 0.4 t cp 0.6 t cp c in xin32 input capacitance 5pf i osc current consumption active mode 1.8 a standby mode 0.1 a
619 32059l?avr32?01/2012 at32uc3b 28.7.3 main oscillators 28.7.4 phase lock loop table 28-18. main oscillators characteristics symbol parameter conditions min. typ. max. unit 1/(t cpmain ) oscillator frequency external clock on xin 50 mhz crystal 0.4 20 mhz c l1 , c l2 internal load capacitance (c l1 = c l2 )7pf esr crystal equivalent series resistance 75 duty cycle 405060 % t st startup time f = 400 khz f = 8 mhz f = 16 mhz f = 20 mhz 25 4 1.4 1 ms t ch xin clock high half-period 0.4 t cp 0.6 t cp t cl xin clock low half-period 0.4 t cp 0.6 t cp c in xin input capacitance 7 pf i osc current consumption active mode at 400 khz. gain = g0 active mode at 8 mhz. gain = g1 active mode at 16 mhz. gain = g2 active mode at 20 mhz. gain = g3 30 45 95 205 a table 28-19. phase lock loop characteristics symbol parameter conditions min. typ. max. unit f out vco output frequency 80 240 mhz f in input frequency 4 16 mhz i pll current consumption active mode f vco @96 mhz active mode f vco @128 mhz active mode f vco @160 mhz 320 410 450 a standby mode 5 a
620 32059l?avr32?01/2012 at32uc3b 28.8 adc characteristics notes: 1. corresponds to 13 clock cycles: 3 cl ock cycles for track and hold acquisition ti me and 10 clock cycles for conversion. 2. corresponds to 15 clock cycles: 5 clock cycles for track and hold acquisition time and 10 clock cycles for conversion. note: 1. advref should be connected to gnd to avoi d extra consumption in case adc is not used. table 28-20. channel conversion time and adc clock parameter conditions min. typ. max. unit adc clock frequency 10-bit resolution mode 5 mhz adc clock frequency 8-bit resolution mode 8 mhz startup time return from idle mode 20 s track and hold acquisition time 600 ns track and hold input resistor 350 track and hold capacitor 12 pf conversion time adc clock = 5 mhz 2 s adc clock = 8 mhz 1.25 s throughput rate adc clock = 5 mhz 384 (1) ksps adc clock = 8 mhz 533 (2) ksps table 28-21. external voltage reference input parameter conditions min. typ. max. unit advref input voltage range (1) 2.6 vddana v advref average current on 13 samples with adc clock = 5 mhz 200 250 a current consumption on vddana on 13 samples with adc clock = 5 mhz 1 ma table 28-22. analog inputs parameter conditions min. typ. max. unit input voltage range 0 v advref v input leakage current 1a input capacitance 7pf table 28-23. transfer characteristics in 8-bit mode parameter conditions min. typ. max. unit resolution 8bit absolute accuracy adc clock = 5 mhz 0.8 lsb adc clock = 8 mhz 1.5 lsb integral non-linearity adc clock = 5 mhz 0.35 0.5 lsb adc clock = 8 mhz 0.5 1.0 lsb
621 32059l?avr32?01/2012 at32uc3b differential non-linearity adc clock = 5 mhz 0.3 0.5 lsb adc clock = 8 mhz 0.5 1.0 lsb offset error adc clock = 5 mhz -0.5 0.5 lsb gain error adc clock = 5 mhz -0.5 0.5 lsb table 28-23. transfer characteristics in 8-bit mode parameter conditions min. typ. max. unit table 28-24. transfer characteristics in 10-bit mode parameter conditions min. typ. max. unit resolution 10 bit absolute accuracy adc clock = 5 mhz 3 lsb integral non-linearity adc clock = 5 mhz 1.5 2 lsb differential non-linearity adc clock = 5 mhz 1 2 lsb adc clock = 2.5 mhz 0.6 1 lsb offset error adc clock = 5 mhz -2 2 lsb gain error adc clock = 5mhz -2 2 lsb
622 32059l?avr32?01/2012 at32uc3b 28.9 usb transceiver characteristics 28.9.1 electrical characteristics the usb on-chip buffers comply with the univ ersal serial bus (usb) v2.0 standard. all ac parameters related to these buffers can be foun d within the usb 2.0 elec trical specifications. table 28-25. electrical parameters symbol parameter conditions min. typ. max. unit r ext recommended external usb series resistor in series with each usb pin with 5% 39
623 32059l?avr32?01/2012 at32uc3b 28.10 jtag characteristics 28.10.1 jtag timing figure 28-6. jtag interface signals note: 1. these values are based on simulation and ch aracterization of other avr microcontrollers manufactured in the same pro-cess technology. these values are not covered by test limits in production. jtag2 jtag3 jtag1 jtag4 jtag0 tms/tdi tck tdo jtag5 jtag6 jtag7 jtag8 jtag9 jtag10 boundary scan inputs boundary scan outputs table 28-26. jtag timings (1) symbol parameter conditions min max units jtag0 tck low half-period v vddio from 3.0v to 3.6v, maximum external capacitor = 40pf 23.2 ns jtag1 tck high half-period 8.8 ns jtag2 tck period 32.0 ns jtag3 tdi, tms setup before tck high 3.9 ns jtag4 tdi, tms hold after tck high 0.6 ns jtag5 tdo hold time 4.5 ns jtag6 tck low to tdo valid 23.2 ns jtag7 boundary scan inputs setup time 0 ns jtag8 boundary scan inputs hold time 5.0 ns jtag9 boundary scan outputs hold time 8.7 ns jtag10 tck to boundary scan outputs valid 17.7 ns
624 32059l?avr32?01/2012 at32uc3b 28.11 spi characteristics figure 28-7. spi master mode with (cpol = ncpha = 0) or (cpol= ncpha= 1) figure 28-8. spi master mode with (cpol=0 and ncpha=1) or (cpol=1 and ncpha=0) figure 28-9. spi slave mode with (cpol=0 and ncpha=1) or (cpol=1 and ncpha=0) spck miso mosi spi 2 spi 0 spi 1 spck miso mosi spi 5 spi 3 spi 4 spck miso mosi spi 6 spi 7 spi 8
625 32059l?avr32?01/2012 at32uc3b figure 28-10. spi slave mode with (cpol = ncph a = 0) or (cpol= ncpha= 1) notes: 1. 3.3v domain: v vddio from 3.0v to 3.6v, maximum external capacitor = 40 pf. 2. t cpmck : master clock period in ns. spck miso mosi spi 9 spi 10 spi 11 table 28-27. spi timings symbol parameter conditions min. max. unit spi 0 miso setup time before spck rises (master) 3.3v domain (1) 22 + (t cpmck )/2 (2) ns spi 1 miso hold time after spck rises (master) 3.3v domain (1) 0ns spi 2 spck rising to mosi delay (master) 3.3v domain (1) 7ns spi 3 miso setup time before spck falls (master) 3.3v domain (1) 22 + (t cpmck )/2 (2) ns spi 4 miso hold time after spck falls (master) 3.3v domain (1) 0ns spi 5 spck falling to mosi delay master) 3.3v domain (1) 7ns spi 6 spck falling to miso delay (slave) 3.3v domain (1) 26.5 ns spi 7 mosi setup time before spck rises (slave) 3.3v domain (1) 0ns spi 8 mosi hold time after spck rises (slave) 3.3v domain (1) 1.5 ns spi 9 spck rising to miso delay (slave) 3.3v domain (1) 27 ns spi 10 mosi setup time before spck falls (slave) 3.3v domain (1) 0ns spi 11 mosi hold time after spck falls (slave) 3.3v domain (1) 1ns
626 32059l?avr32?01/2012 at32uc3b 28.12 flash memory characteristics the following table gives the device maximum op erating frequency depending on the field fws of the flash fsr register. this fi eld defines the number of wait states required to access the flash memory. flash operating freque ncy equals the cpu/hsb frequency. table 28-28. flash operating frequency symbol parameter conditions min. typ. max. unit f fop flash operating frequency fws = 0 33 mhz fws = 1 60 mhz table 28-29. programming time symbol parameter conditions min. typ. max. unit t fpp page programming time 4 ms t ffp fuse programming time 0.5 ms t fce chip erase time 4ms table 28-30. flash parameters symbol parameter conditions min. typ. max. unit n farray flash array write/erase cycle 100k cycle n ffuse general purpose fuses write cycle 1000 cycle t fdr flash data retention time 15 year
627 32059l?avr32?01/2012 at32uc3b 29. mechanical characteristics 29.1 thermal considerations 29.1.1 thermal data table 29-1 summarizes the thermal resistance data depending on the package. 29.1.2 junction temperature the average chip-junction temperature, t j , in c can be obtained from the following: 1. 2. where: ? ja = package thermal resistance, junction-to-ambient (c/w), provided in table 29-1 on page 627 . ? jc = package thermal resistance, junction-to-case thermal resistance (c/w), provided in table 29-1 on page 627 . ? heat sink = cooling device thermal resistance (c/w), provided in the device datasheet. ?p d = device power consumption (w) estimate d from data provided in the section ?power consumption? on page 614 . ?t a = ambient temperature (c). from the first equation, the user can derive the estimated lifetime of the chip and decide if a cooling device is necessary or not. if a coolin g device is to be fitted on the chip, the second equation should be used to compute the re sulting average chip-junction temperature t j in c. table 29-1. thermal resistance data symbol parameter condition package typ unit ja junction-to-ambient thermal resistance still air tqfp64 49.6 ? c/w jc junction-to-case thermal resistance tqfp64 13.5 ja junction-to-ambient thermal resistance still air tqfp48 51.1 ? c/w jc junction-to-case thermal resistance tqfp48 13.7 t j t a p d ja () + = t j t a p ( d ( heatsink jc )) ++ =
628 32059l?avr32?01/2012 at32uc3b 29.2 package drawings figure 29-1. tqfp-64 package drawing table 29-2. device and package maximum weight weight 300 mg table 29-3. package characteristics moisture sensitivity level jedec j-std-20d-msl3 table 29-4. package reference jedec drawing reference ms-026 jesd97 classification e3
629 32059l?avr32?01/2012 at32uc3b figure 29-2. tqfp-48 package drawing table 29-5. device and package maximum weight weight 100 mg table 29-6. package characteristics moisture sensitivity level jedec j-std-20d-msl3 table 29-7. package reference jedec drawing reference ms-026 jesd97 classification e3
630 32059l?avr32?01/2012 at32uc3b figure 29-3. qfn-64 package drawing table 29-8. device and package maximum weight weight 200 mg table 29-9. package characteristics moisture sensitivity level jedec j-std-20d-msl3 table 29-10. package reference jedec drawing reference m0-220 jesd97 classification e3
631 32059l?avr32?01/2012 at32uc3b figure 29-4. qfn-48 package drawing table 29-11. device and package maximum weight weight 100 mg table 29-12. package characteristics moisture sensitivity level jedec j-std-20d-msl3 table 29-13. package reference jedec drawing reference m0-220 jesd97 classification e3
632 32059l?avr32?01/2012 at32uc3b 29.3 soldering profile table 29-14 gives the recommended soldering profile from j-std-20. note: it is recommended to apply a soldering temperature higher than 250c. a maximum of three reflow passes is allowed per component. table 29-14. soldering profile profile feature green package average ramp-up rate (217c to peak) 3c/s preheat temperature 175c 25c min. 150c, max. 200c temperature maintained above 217c 60-150s time within 5 ? c of actual peak temperature 30s peak temperature range 260c ramp-down rate 6c/s time 25 ? c to peak temperature max. 8mn
633 32059l?avr32?01/2012 at32uc3b 30. ordering information device ordering code package conditioning temperature operating range at32uc3b0512 at32uc3b0512-a2ues tqfp 64 - industrial (-40 c to 85 c) at32uc3b0512-a2ur tqfp 64 reel industrial (-40 c to 85 c) at32uc3b0512-a2ut tqfp 64 tray industrial (-40 c to 85 c) at32uc3b0512-z2ues qfn 64 - industrial (-40 c to 85 c) at32uc3b0512-z2ur qfn 64 reel industrial (-40 c to 85 c) at32uc3b0512-z2ut qfn 64 tray industrial (-40 c to 85 c) at32uc3b0256 at32uc3b0256-a2ut tqfp 64 tray industrial (-40 c to 85 c) at32uc3b0256-a2ur tqfp 64 reel industrial (-40 c to 85 c) at32uc3b0256-z2ut qfn 64 tray industrial (-40 c to 85 c) at32uc3b0256-z2ur qfn 64 reel industrial (-40 c to 85 c) at32uc3b0128 at32uc3b0128-a2ut tqfp 64 tray industrial (-40 c to 85 c) at32uc3b0128-a2ur tqfp 64 reel industrial (-40 c to 85 c) at32uc3b0128-z2ut qfn 64 tray industrial (-40 c to 85 c) at32uc3b0128-z2ur qfn 64 reel industrial (-40 c to 85 c) at32uc3b064 at32uc3b064-a2ut tqfp 64 tray industrial (-40 c to 85 c) at32uc3b064-a2ur tqfp 64 reel industrial (-40 c to 85 c) at32uc3b064-z2ut qfn 64 tray industrial (-40 c to 85 c) at32uc3b064-z2ur qfn 64 reel industrial (-40 c to 85 c) at32uc3b1512 at32uc3b1512-z1ut qfn 48 - industrial (-40 c to 85 c) at32uc3b1512-z1ur qfn 48 - industrial (-40 c to 85 c) at32uc3b1256 at32uc3b1256-aut tqfp 48 tray industrial (-40 c to 85 c) at32uc3b1256-aur tqfp 48 reel industrial (-40 c to 85 c) at32uc3b1256-z1ut qfn 48 tray industrial (-40 c to 85 c) at32uc3b1256-z1ur qfn 48 reel industrial (-40 c to 85 c) at32uc3b1128 at32uc3b1128-aut tqfp 48 tray industrial (-40 c to 85 c) at32uc3b1128-aur tqfp 48 reel industrial (-40 c to 85 c) at32uc3b1128-z1ut qfn 48 tray industrial (-40 c to 85 c) at32uc3b1128-z1ur qfn 48 reel industrial (-40 c to 85 c) at32uc3b164 at32uc3b164-aut tqfp 48 tray industrial (-40 c to 85 c) at32uc3b164-aur tqfp 48 reel industrial (-40 c to 85 c) at32uc3b164-z1ut qfn 48 tray industrial (-40 c to 85 c) at32uc3b164-z1ur qfn 48 reel industrial (-40 c to 85 c)
634 32059l?avr32?01/2012 at32uc3b 31. errata 31.1 at32uc3b0512, at32uc3b1512 31.1.1 rev d - pwm 1. pwm channel interrupt enabling triggers an interrupt when enabling a pwm channel that is configured with center aligned period (calg=1), an interrupt is signalled. fix/workaround when using center aligned mode, enable the channel and read the status before channel interrupt is enabled. 2. pwn counter restarts at 0x0001 the pwm counter restarts at 0x0001 and not 0x0000 as specified. because of this the first pwm period has one more clock cycle. fix/workaround - the first period is 0x0000, 0x0001, ..., period. - consecutive periods are 0x0001, 0x0002, ..., period. 3. pwm update period to a 0 value does not work it is impossible to update a period equal to 0 by the using the pwm update register (pwm_cupd). fix/workaround do not update the pwm_cupd register with a value equal to 0. 4. spi 5. spi slave / pdca tran sfer: no tx underrun flag there is no tx underrun flag available, therefore in spi slave mode, there is no way to be informed of a character lost in transmission. fix/workaround for pdca transfer: none. 6. spi bad serial clock generation on 2nd chip_select when scbr=1, cpol=1, and ncpha=0 when multiple chip selects (cs) are in use, if one of the baudrates equal 1 while one (csrn.scbr=1) of the others do not equal 1, and csrn.cpol=1 and csrn.ncpha=0, then an additional pulse will be genera ted on sck. fix/workaround when multiple cs are in use, if one of the b audrates equals 1, the othe rs must also equal 1 if csrn.cpol=1 and csrn.ncpha=0.
635 32059l?avr32?01/2012 at32uc3b 7. spi glitch on rxready flag in slave mode when enabling the spi or during the first transfer in slave mode, the spi can generate a false rxready signal during enabling of the spi or during the first transfer. fix/workaround 1. set slave mode, set required cpol/cpha. 2. enable spi. 3. set the polarity cpol of the line in the opposite value of the required one. 4. set the polarity cpol to the required one. 5. read the rxholding register. transfers can now begin and rxr eady will now behave as expected. 8. spi disable does not work in slave mode spi disable does not work in slave mode. fix/workaround read the last received data, then perform a so ftware reset by writing a one to the software reset bit in the control register (cr.swrst). 9. spi data transfer hangs with csr0.csaat==1 and mr.modfdis==0 when csr0.csaat==1 and mode fault detection is enabled (mr.modfdis==0), the spi module will not start a data transfer. fix/workaround disable mode fault detection by writing a one to mr.modfdis. 10. disabling spi has no effect on the sr.tdre bit disabling spi has no effect on the sr.tdre bit whereas the write data command is filtered when spi is disabled. writing to tdr when spi is disabled will not clear sr.tdre. if spi is disabled during a pdca transfer, the pdca will continue to write data to tdr until its buffer is empty, and this data will be lost. fix/workaround disable the pdca, add two nops, and disable t he spi. to continue the transfer, enable the spi and pdca. 11. power manager 12. if the bod level is higher than vd dcore, the part is constantly reset if the bod level is set to a value higher than vddcore and enabled by fuses, the part will be in constant reset. fix/workaround apply an external voltage on vddcore that is higher than the bod le vel and is lower than vddcore max and disable the bod. 13. when the main clock is rcsys, ti mer_clock5 is eq ual to pba clock when the main clock is gen erated from rcsys, timer_cl ock5 is equal to pba clock and not pba clock / 128. fix/workaround none. 14. clock sources will not be stopped in static sleep mode if the difference between cpu and pbx division factor is too high if the division factor between the cpu/hsb and pbx frequencies is more than 4 when going to a sleep mode where the system rc oscillator is turned off, then high speed clock sources
636 32059l?avr32?01/2012 at32uc3b will not be turned off. this will result in a significantly higher power consumption during the sleep mode. fix/workaround before going to sleep modes w here the system rc oscillator is stopped, make sure that the factor between the cpu/hsb and pbx frequen cies is less than or equal to 4. 15. increased power consumption in vddio in sleep modes if the osc0 is enabled in crystal mode when entering a sleep mode where the osc0 is dis- abled, this will lead to an increased power consumption in vddio. fix/workaround disable the osc0 through the power manager (pm) before going to any sleep mode where the osc0 is disabled, or pull down or up xin0 and xout0 with 1mohm resistor. 16. ssc 17. additional delay on td output a delay from 2 to 3 system clock cy cles is added to td output when: tcmr.start = receive start, tcmr.sttdly = more than zero, rcmr.start = start on falling edge / start on rising edge / start on any edge, rfmr.fsos = none (input). fix/workaround none. 18. tf output is not correct tf output is not correct (at least emitted one serial clock cycle later than expected) when: tfmr.fsos = driven low during data transfer/ driven high during data transfer tcmr.start = receive start rfmr.fsos = none (input) rcmr.start = any on rf (edge/level) fix/workaround none. 19. frame synchro and frame synchro data are delayed by one clock cycle the frame synchro and the frame synchro data are delayed from 1 ssc_clock when: - clock is ckdiv - the start is selected on either a frame synchro edge or a level - frame synchro data is enabled - transmit clock is gated on output (through cko field) fix/workaround transmit or receive clock must not be gated (by the mean of cko field) when start condition is performed on a generated frame synchro.
637 32059l?avr32?01/2012 at32uc3b 20. usb 21. upcfgn.intfrq is irrelevant for isochronous pipe as a consequence, isochronous in and out to kens are sent every 1ms (full speed), or every 125us (high speed). fix/workaround for higher polling time, the software must freeze the pipe for the desired period in order to prevent any "extra" token. - adc 1. sleep mode activation needs additional a to d conversion if the adc sleep mode is activated when the ad c is idle the adc w ill not enter sleep mode before after the next ad conversion. fix/workaround activate the sleep mode in the mode regi ster and then perform an ad conversion. - pdca 1. wrong pdca behavior when using tw o pdca channels with the same pid wrong pdca behavior when using tw o pdca channels with the same pid. fix/workaround the same pid should not be assigned to more than one channel. 2. transfer error will stall a transm it peripheral hand shake interface if a transfer error is encountered on a channel transmitting to a peripheral, the peripheral handshake of the active channel will stall and the pdca will not do any more transfers on the affected peripheral handshake interface. fix/workaround disable and then enable the peripheral after the transfer error. 3. twi 4. the twi rxrdy flag in sr register is no t reset when a software reset is performed the twi rxrdy flag in sr register is not reset when a software reset is performed. fix/workaround after a software reset, the regi ster twi rhr must be read. 5. twi in master mode will continue to read data twi in master mode will continue to read data on the line even if the shift register and the rhr register are full. this w ill generate an overrun error. fix/workaround to prevent this, read the rhr register as soon as a new rx data is ready. 6. twi slave behaves improperly if master acknowledges the last transmitted data byte before a stop condition in i2c slave transmitter mode, if the master acknowledges the last data byte before a stop condition (what the master is not supposed to do), the following twi slave receiver mode frame may contain an inappropriate clock stretch. this clock stretch can only be stopped by resetting the twi. fix/workaround if the twi is used as a slave transmitter with a master that acknowledges the last data byte before a stop condition, it is necessary to reset the twi before entering slave receiver mode.
638 32059l?avr32?01/2012 at32uc3b 7. tc 8. channel chaining skips first pulse for upper channel when chaining two channels using the block mode register, the first pulse of the clock between the channels is skipped. fix/workaround configure the lower channel with ra = 0x1 and rc = 0x2 to produce a dummy clock cycle for the upper channel. after the dummy cyc le has been generated, indicated by the sr.cpcs bit, reconfigure the ra and rc registers for the lower channel with the real values. - processor and architecture 1. ldm instruction with pc in the regist er list and without ++ increments rp for ldm with pc in the register list: the instruction behaves as if the ++ field is always set, ie the pointer is alwa ys updated. this happens even if the ++ field is cleared. specifically, the increment of the pointer is done in parallel with the testing of r12. fix/workaround none. 2. rete instruction does not clear sreg[l] from interrupts the rete instruction clears sreg[l] as expected from exceptions. fix/workaround when using the stcond instruct ion, clear sreg[l] in the stacked value of sr before returning from inte rrupts with rete. 3. privilege violation when using interrupts in application mode with protected system stack if the system stack is protec ted by the mpu and an interrupt occurs in application mode, an mpu dtlb exception will occur. fix/workaround make a dtlb protection (write) exception handler which permits the interrupt request to be handled in privileged mode. 4. usart 5. iso7816 info register us_ner cannot be read the ner register always returns zero. fix/workaround none. 6. iso7816 mode t1: rx impossible after any tx rx impossible after any tx. fix/workaround soft_reset on rx+ config us_mr + config_us_cr. 7. the rts output does not function corr ectly in hardware handshaking mode the rts signal is not generated properly when the usart receives data in hardware hand- shaking mode. when the peripheral dma receive buffer becomes full, the rts output should go high, bu t it will stay low. fix/workaround do not use the hardware handshaking mode of the usart. if it is necessary to drive the rts output high when the peripheral dma receive buffer becomes full, use the normal mode of the usart. configure the peripheral dma controller to signal an interrupt when
639 32059l?avr32?01/2012 at32uc3b the receive buffer is full. in the interrupt handler code, write a one to the rtsdis bit in the usart control register (cr). this will drive th e rts output high. afte r the next dma trans- fer is started and a receive buffer is availabl e, write a one to the rtsen bit in the usart cr so that rts will be driven low. 8. corruption after receiving too many bits in spi slave mode if the usart is in spi slave mode and receives too much data bits (ex: 9bitsinstead of 8 bits) by the spi master, an error occurs. after that, the next reception may be corrupted even if the frame is correct and the usart has been disabled, reset by a soft reset and re- enabled. fix/workaround none. 9. usart slave synchronous mode external clock must be at least 9 times lower in fre- quency than clk_usart when the usart is operating in slave synchr onous mode with an external clock, the fre- quency of the signal provided on clk must be at least 9 times lower than clk_usart. fix/workaround when the usart is operating in slave synchro nous mode with an external clock, provide a signal on clk that has a frequency at least 9 times lower than clk_usart. 10. hmatrix 11. in the pras and prbs registers, the mxpr fields are only two bits in the pras and prbs registers, the mxpr fields are only two bits wide, instead of four bits. the unused bits are undefined when reading the registers. fix/workaround mask undefined bits when reading pras and prbs. - dsp operations 1. hardware breakpoints may corrupt mac results hardware breakpoints on mac in structions may corrupt the dest ination register of the mac instruction. fix/workaround place breakpoints on earlier or later instructions.
640 32059l?avr32?01/2012 at32uc3b 31.1.2 rev c - pwm 1. pwm channel interrupt enabling triggers an interrupt when enabling a pwm channel that is configured with center aligned period (calg=1), an interrupt is signalled. fix/workaround when using center aligned mode, enable the channel and read the status before channel interrupt is enabled. 2. pwn counter restarts at 0x0001 the pwm counter restarts at 0x0001 and not 0x0000 as specified. because of this the first pwm period has one more clock cycle. fix/workaround - the first period is 0x0000, 0x0001, ..., period. - consecutive periods are 0x0001, 0x0002, ..., period. 3. pwm update period to a 0 value does not work it is impossible to update a period equal to 0 by the using the pwm update register (pwm_cupd). fix/workaround do not update the pwm_cupd register with a value equal to 0. 4. spi 5. spi slave / pdca tran sfer: no tx underrun flag there is no tx underrun flag available, therefore in spi slave mode, there is no way to be informed of a character lost in transmission. fix/workaround for pdca transfer: none. 6. spi bad serial clock generation on 2nd chip_select when scbr=1, cpol=1, and ncpha=0 when multiple chip selects (cs) are in use, if one of the baudrates equal 1 while one (csrn.scbr=1) of the others do not equal 1, and csrn.cpol=1 and csrn.ncpha=0, then an additional pulse will be genera ted on sck. fix/workaround when multiple cs are in use, if one of the b audrates equals 1, the othe rs must also equal 1 if csrn.cpol=1 and csrn.ncpha=0. 7. spi glitch on rxready flag in slave mode when enabling the spi or during the first transfer in slave mode, the spi can generate a false rxready signal during enabling of the spi or during the first transfer. fix/workaround 1. set slave mode, set required cpol/cpha. 2. enable spi. 3. set the polarity cpol of the line in the opposite value of the required one. 4. set the polarity cpol to the required one. 5. read the rxholding register. transfers can now begin and rxr eady will now behave as expected.
641 32059l?avr32?01/2012 at32uc3b 8. spi disable does not work in slave mode spi disable does not work in slave mode. fix/workaround read the last received data, then perform a so ftware reset by writing a one to the software reset bit in the control register (cr.swrst). 9. spi data transfer hangs with csr0.csaat==1 and mr.modfdis==0 when csr0.csaat==1 and mode fault detection is enabled (mr.modfdis==0), the spi module will not start a data transfer. fix/workaround disable mode fault detection by writing a one to mr.modfdis. 10. disabling spi has no effect on the sr.tdre bit disabling spi has no effect on the sr.tdre bit whereas the write data command is filtered when spi is disabled. writing to tdr when spi is disabled will not clear sr.tdre. if spi is disabled during a pdca transfer, the pdca will continue to write data to tdr until its buffer is empty, and this data will be lost. fix/workaround disable the pdca, add two nops, and disable t he spi. to continue the transfer, enable the spi and pdca. 11. power manager 12. if the bod level is higher than vd dcore, the part is constantly reset if the bod level is set to a value higher than vddcore and enabled by fuses, the part will be in constant reset. fix/workaround apply an external voltage on vddcore that is higher than the bod le vel and is lower than vddcore max and disable the bod. 13. when the main clock is rcsys, ti mer_clock5 is eq ual to pba clock when the main clock is gen erated from rcsys, timer_cl ock5 is equal to pba clock and not pba clock / 128. fix/workaround none. 14. vddcore power supply input needs to be 1.95v when used in dual power supply, vddcore needs to be 1.95v. fix/workaround when used in single power supply, vddcore ne eds to be connected to vddout, which is configured on revision c at 1.95v (typ.). 15. clock sources will not be stopped in static sleep mode if the difference between cpu and pbx division factor is too high if the division factor between the cpu/hsb and pbx frequencies is more than 4 when going to a sleep mode where the system rc oscillator is turned off, then high speed clock sources will not be turned off. this will result in a significantly higher power consumption during the sleep mode. fix/workaround before going to sleep modes w here the system rc oscillator is stopped, make sure that the factor between the cpu/hsb and pbx frequen cies is less than or equal to 4.
642 32059l?avr32?01/2012 at32uc3b 16. increased power consumption in vddio in sleep modes if the osc0 is enabled in crystal mode when entering a sleep mode where the osc0 is dis- abled, this will lead to an increased power consumption in vddio. fix/workaround disable the osc0 through the power manager (pm) before going to any sleep mode where the osc0 is disabled, or pull down or up xin0 and xout0 with 1mohm resistor. 17. ssc 18. additional delay on td output a delay from 2 to 3 system clock cy cles is added to td output when: tcmr.start = receive start, tcmr.sttdly = more than zero, rcmr.start = start on falling edge / start on rising edge / start on any edge, rfmr.fsos = none (input). fix/workaround none. 19. tf output is not correct tf output is not correct (at least emitted one serial clock cycle later than expected) when: tfmr.fsos = driven low during data transfer/ driven high during data transfer tcmr.start = receive start rfmr.fsos = none (input) rcmr.start = any on rf (edge/level) fix/workaround none. 20. frame synchro and frame synchro data are delayed by one clock cycle the frame synchro and the frame synchro data are delayed from 1 ssc_clock when: - clock is ckdiv - the start is selected on either a frame synchro edge or a level - frame synchro data is enabled - transmit clock is gated on output (through cko field) fix/workaround transmit or receive clock must not be gated (by the mean of cko field) when start condition is performed on a generated frame synchro. 21. usb 22. upcfgn.intfrq is irrelevant for isochronous pipe as a consequence, isochronous in and out to kens are sent every 1ms (full speed), or every 125us (high speed). fix/workaround for higher polling time, the software must freeze the pipe for the desired period in order to prevent any "extra" token. - adc 1. sleep mode activation needs additional a to d conversion if the adc sleep mode is activated when the ad c is idle the adc w ill not enter sleep mode before after the next ad conversion. fix/workaround activate the sleep mode in the mode regi ster and then perform an ad conversion.
643 32059l?avr32?01/2012 at32uc3b - pdca 1. wrong pdca behavior when using tw o pdca channels with the same pid wrong pdca behavior when using tw o pdca channels with the same pid. fix/workaround the same pid should not be assigned to more than one channel. 2. transfer error will stall a transm it peripheral hand shake interface if a transfer error is encountered on a channel transmitting to a peripheral, the peripheral handshake of the active channel will stall and the pdca will not do any more transfers on the affected peripheral handshake interface. fix/workaround disable and then enable the peripheral after the transfer error. 3. twi 4. the twi rxrdy flag in sr register is no t reset when a software reset is performed the twi rxrdy flag in sr register is not reset when a software reset is performed. fix/workaround after a software reset, the regi ster twi rhr must be read. 5. twi in master mode will continue to read data twi in master mode will continue to read data on the line even if the shift register and the rhr register are full. this w ill generate an overrun error. fix/workaround to prevent this, read the rhr register as soon as a new rx data is ready. 6. twi slave behaves improperly if master acknowledges the last transmitted data byte before a stop condition in i2c slave transmitter mode, if the master acknowledges the last data byte before a stop condition (what the master is not supposed to do), the following twi slave receiver mode frame may contain an inappropriate clock stretch. this clock stretch can only be stopped by resetting the twi. fix/workaround if the twi is used as a slave transmitter with a master that acknowledges the last data byte before a stop condition, it is necessary to reset the twi before entering slave receiver mode. 7. tc 8. channel chaining skips first pulse for upper channel when chaining two channels using the block mode register, the first pulse of the clock between the channels is skipped. fix/workaround configure the lower channel with ra = 0x1 and rc = 0x2 to produce a dummy clock cycle for the upper channel. after the dummy cyc le has been generated, indicated by the sr.cpcs bit, reconfigure the ra and rc registers for the lower channel with the real values.
644 32059l?avr32?01/2012 at32uc3b - processor and architecture 1. ldm instruction with pc in the regist er list and without ++ increments rp for ldm with pc in the register list: the instruction behaves as if the ++ field is always set, ie the pointer is alwa ys updated. this happens even if the ++ field is cleared. specifically, the increment of the pointer is done in parallel with the testing of r12. fix/workaround none. 2. rete instruction does not clear sreg[l] from interrupts the rete instruction clears sreg[l] as expected from exceptions. fix/workaround when using the stcond instruct ion, clear sreg[l] in the stacked value of sr before returning from inte rrupts with rete. 3. privilege violation when using interrupts in application mode with protected system stack if the system stack is protec ted by the mpu and an interrupt occurs in application mode, an mpu dtlb exception will occur. fix/workaround make a dtlb protection (write) exception handler which permits the interrupt request to be handled in privileged mode. 4. flash 5. reset vector is 80000020h rather than 80000000h reset vector is 80000020h rather than 80000000h. fix/workaround the flash program code must start at the address 80000020h. the flash memory range 80000000h-80000020h must be programmed with 00000000h. - usart 1. iso7816 info register us_ner cannot be read the ner register always returns zero. fix/workaround none. 2. iso7816 mode t1: rx impossible after any tx rx impossible after any tx. fix/workaround soft_reset on rx+ config us_mr + config_us_cr. 3. the rts output does not function corr ectly in hardware handshaking mode the rts signal is not generated properly when the usart receives data in hardware hand- shaking mode. when the peripheral dma receive buffer becomes full, the rts output should go high, bu t it will stay low. fix/workaround do not use the hardware handshaking mode of the usart. if it is necessary to drive the rts output high when the peripheral dma receive buffer becomes full, use the normal mode of the usart. configure the peripheral dma controller to signal an interrupt when the receive buffer is full. in the interrupt handler code, write a one to the rtsdis bit in the usart control register (cr). this will drive th e rts output high. afte r the next dma trans-
645 32059l?avr32?01/2012 at32uc3b fer is started and a receive buffer is availabl e, write a one to the rtsen bit in the usart cr so that rts will be driven low. 4. corruption after receiving too many bits in spi slave mode if the usart is in spi slave mode and receives too much data bits (ex: 9bitsinstead of 8 bits) by the spi master, an error occurs. after that, the next reception may be corrupted even if the frame is correct and the usart has been disabled, reset by a soft reset and re- enabled. fix/workaround none. 5. usart slave synchronous mode external clock must be at least 9 times lower in fre- quency than clk_usart when the usart is operating in slave synchr onous mode with an external clock, the fre- quency of the signal provided on clk must be at least 9 times lower than clk_usart. fix/workaround when the usart is operating in slave synchro nous mode with an external clock, provide a signal on clk that has a frequency at least 9 times lower than clk_usart. 6. hmatrix 7. in the pras and prbs registers, the mxpr fields are only two bits in the pras and prbs registers, the mxpr fields are only two bits wide, instead of four bits. the unused bits are undefined when reading the registers. fix/workaround mask undefined bits when reading pras and prbs. - dsp operations 1. hardware breakpoints may corrupt mac results hardware breakpoints on mac in structions may corrupt the dest ination register of the mac instruction. fix/workaround place breakpoints on earlier or later instructions.
646 32059l?avr32?01/2012 at32uc3b 31.2 at32uc3b0256, at32uc3b0128, at32uc3 b064, at32uc3b1256, at32uc3b1128, at32uc3b164 all industrial parts labelled with -ues (for engineering samples) are revision b parts. 31.2.1 rev i, j, k - pwm 1. pwm channel interrupt enabling triggers an interrupt when enabling a pwm channel that is configured with center aligned period (calg=1), an interrupt is signalled. fix/workaround when using center aligned mode, enable the channel and read the status before channel interrupt is enabled. 2. pwn counter restarts at 0x0001 the pwm counter restarts at 0x0001 and not 0x0000 as specified. because of this the first pwm period has one more clock cycle. fix/workaround - the first period is 0x0000, 0x0001, ..., period. - consecutive periods are 0x0001, 0x0002, ..., period. 3. pwm update period to a 0 value does not work it is impossible to update a period equal to 0 by the using the pwm update register (pwm_cupd). fix/workaround do not update the pwm_cupd register with a value equal to 0. 4. spi 5. spi slave / pdca tran sfer: no tx underrun flag there is no tx underrun flag available, therefore in spi slave mode, there is no way to be informed of a character lost in transmission. fix/workaround for pdca transfer: none. 6. spi bad serial clock generation on 2nd chip_select when scbr=1, cpol=1, and ncpha=0 when multiple chip selects (cs) are in use, if one of the baudrates equal 1 while one (csrn.scbr=1) of the others do not equal 1, and csrn.cpol=1 and csrn.ncpha=0, then an additional pulse will be genera ted on sck. fix/workaround when multiple cs are in use, if one of the b audrates equals 1, the othe rs must also equal 1 if csrn.cpol=1 and csrn.ncpha=0. 7. spi glitch on rxready flag in slave mode when enabling the spi or during the first transfer in slave mode, the spi can generate a false rxready signal during enabling of the spi or during the first transfer. fix/workaround 1. set slave mode, set required cpol/cpha. 2. enable spi.
647 32059l?avr32?01/2012 at32uc3b 3. set the polarity cpol of the line in the opposite value of the required one. 4. set the polarity cpol to the required one. 5. read the rxholding register. transfers can now begin and rxr eady will now behave as expected. 8. spi disable does not work in slave mode spi disable does not work in slave mode. fix/workaround read the last received data, then perform a so ftware reset by writing a one to the software reset bit in the control register (cr.swrst). 9. spi data transfer hangs with csr0.csaat==1 and mr.modfdis==0 when csr0.csaat==1 and mode fault detection is enabled (mr.modfdis==0), the spi module will not start a data transfer. fix/workaround disable mode fault detection by writing a one to mr.modfdis. 10. disabling spi has no effect on the sr.tdre bit disabling spi has no effect on the sr.tdre bit whereas the write data command is filtered when spi is disabled. writing to tdr when spi is disabled will not clear sr.tdre. if spi is disabled during a pdca transfer, the pdca will continue to write data to tdr until its buffer is empty, and this data will be lost. fix/workaround disable the pdca, add two nops, and disable t he spi. to continue the transfer, enable the spi and pdca. 11. power manager 12. if the bod level is higher than vd dcore, the part is constantly reset if the bod level is set to a value higher than vddcore and enabled by fuses, the part will be in constant reset. fix/workaround apply an external voltage on vddcore that is higher than the bod le vel and is lower than vddcore max and disable the bod. 1. when the main clock is rcsys, ti mer_clock5 is eq ual to pba clock when the main clock is gen erated from rcsys, timer_cl ock5 is equal to pba clock and not pba clock / 128. fix/workaround none. 13. clock sources will not be stopped in static sleep mode if the difference between cpu and pbx division factor is too high if the division factor between the cpu/hsb and pbx frequencies is more than 4 when going to a sleep mode where the system rc oscillator is turned off, then high speed clock sources will not be turned off. this will result in a significantly higher power consumption during the sleep mode. fix/workaround before going to sleep modes w here the system rc oscillator is stopped, make sure that the factor between the cpu/hsb and pbx frequen cies is less than or equal to 4.
648 32059l?avr32?01/2012 at32uc3b 14. ssc 15. additional delay on td output a delay from 2 to 3 system clock cy cles is added to td output when: tcmr.start = receive start, tcmr.sttdly = more than zero, rcmr.start = start on falling edge / start on rising edge / start on any edge, rfmr.fsos = none (input). fix/workaround none. 16. tf output is not correct tf output is not correct (at least emitted one serial clock cycle later than expected) when: tfmr.fsos = driven low during data transfer/ driven high during data transfer tcmr.start = receive start rfmr.fsos = none (input) rcmr.start = any on rf (edge/level) fix/workaround none. 17. frame synchro and frame synchro data are delayed by one clock cycle the frame synchro and the frame synchro data are delayed from 1 ssc_clock when: - clock is ckdiv - the start is selected on either a frame synchro edge or a level - frame synchro data is enabled - transmit clock is gated on output (through cko field) fix/workaround transmit or receive clock must not be gated (by the mean of cko field) when start condition is performed on a generated frame synchro. 18. usb 19. upcfgn.intfrq is irrelevant for isochronous pipe as a consequence, isochronous in and out to kens are sent every 1ms (full speed), or every 125us (high speed). fix/workaround for higher polling time, the software must freeze the pipe for the desired period in order to prevent any "extra" token. - adc 1. sleep mode activation needs additional a to d conversion if the adc sleep mode is activated when the ad c is idle the adc w ill not enter sleep mode before after the next ad conversion. fix/workaround activate the sleep mode in the mode regi ster and then perform an ad conversion. - pdca 1. wrong pdca behavior when using tw o pdca channels with the same pid wrong pdca behavior when using tw o pdca channels with the same pid. fix/workaround the same pid should not be assigned to more than one channel.
649 32059l?avr32?01/2012 at32uc3b 2. transfer error will stall a transm it peripheral hand shake interface if a transfer error is encountered on a channel transmitting to a peripheral, the peripheral handshake of the active channel will stall and the pdca will not do any more transfers on the affected peripheral handshake interface. fix/workaround disable and then enable the peripheral after the transfer error. 3. twi 4. the twi rxrdy flag in sr register is no t reset when a software reset is performed the twi rxrdy flag in sr register is not reset when a software reset is performed. fix/workaround after a software reset, the regi ster twi rhr must be read. 5. twi in master mode will continue to read data twi in master mode will continue to read data on the line even if the shift register and the rhr register are full. this w ill generate an overrun error. fix/workaround to prevent this, read the rhr register as soon as a new rx data is ready. 6. twi slave behaves improperly if master acknowledges the last transmitted data byte before a stop condition in i2c slave transmitter mode, if the master acknowledges the last data byte before a stop condition (what the master is not supposed to do), the following twi slave receiver mode frame may contain an inappropriate clock stretch. this clock stretch can only be stopped by resetting the twi. fix/workaround if the twi is used as a slave transmitter with a master that acknowledges the last data byte before a stop condition, it is necessary to reset the twi before entering slave receiver mode. 7. tc 8. channel chaining skips first pulse for upper channel when chaining two channels using the block mode register, the first pulse of the clock between the channels is skipped. fix/workaround configure the lower channel with ra = 0x1 and rc = 0x2 to produce a dummy clock cycle for the upper channel. after the dummy cyc le has been generated, indicated by the sr.cpcs bit, reconfigure the ra and rc registers for the lower channel with the real values. - ocd 1. the auxiliary trace does not work for cpu/hsb sp eed higher than 50mhz the auxiliary trace does not work for cpu/hsb speed higher than 50mhz. fix/workaround do not use the auxiliary trace for cpu/hsb speed hig her than 50mhz.
650 32059l?avr32?01/2012 at32uc3b - processor and architecture 1. ldm instruction with pc in the regist er list and without ++ increments rp for ldm with pc in the register list: the instruction behaves as if the ++ field is always set, ie the pointer is alwa ys updated. this happens even if the ++ field is cleared. specifically, the increment of the pointer is done in parallel with the testing of r12. fix/workaround none. 2. rete instruction does not clear sreg[l] from interrupts the rete instruction clears sreg[l] as expected from exceptions. fix/workaround when using the stcond instruct ion, clear sreg[l] in the stacked value of sr before returning from inte rrupts with rete. 3. privilege violation when using interrupts in application mode with protected system stack if the system stack is protec ted by the mpu and an interrupt occurs in application mode, an mpu dtlb exception will occur. fix/workaround make a dtlb protection (write) exception handler which permits the interrupt request to be handled in privileged mode. 4. usart 5. iso7816 info register us_ner cannot be read the ner register always returns zero. fix/workaround none. 6. iso7816 mode t1: rx impossible after any tx rx impossible after any tx. fix/workaround soft_reset on rx+ config us_mr + config_us_cr. 7. the rts output does not function corr ectly in hardware handshaking mode the rts signal is not generated properly when the usart receives data in hardware hand- shaking mode. when the peripheral dma receive buffer becomes full, the rts output should go high, bu t it will stay low. fix/workaround do not use the hardware handshaking mode of the usart. if it is necessary to drive the rts output high when the peripheral dma receive buffer becomes full, use the normal mode of the usart. configure the peripheral dma controller to signal an interrupt when the receive buffer is full. in the interrupt handler code, write a one to the rtsdis bit in the usart control register (cr). this will drive th e rts output high. afte r the next dma trans- fer is started and a receive buffer is availabl e, write a one to the rtsen bit in the usart cr so that rts will be driven low. 8. corruption after receiving too many bits in spi slave mode if the usart is in spi slave mode and receives too much data bits (ex: 9bitsinstead of 8 bits) by the spi master, an error occurs. after that, the next reception may be corrupted
651 32059l?avr32?01/2012 at32uc3b even if the frame is correct and the usart has been disabled, reset by a soft reset and re- enabled. fix/workaround none. 9. usart slave synchronous mode external clock must be at least 9 times lower in fre- quency than clk_usart when the usart is operating in slave synchr onous mode with an external clock, the fre- quency of the signal provided on clk must be at least 9 times lower than clk_usart. fix/workaround when the usart is operating in slave synchro nous mode with an external clock, provide a signal on clk that has a frequency at least 9 times lower than clk_usart. 10. hmatrix 11. in the pras and prbs registers, the mxpr fields are only two bits in the pras and prbs registers, the mxpr fields are only two bits wide, instead of four bits. the unused bits are undefined when reading the registers. fix/workaround mask undefined bits when reading pras and prbs. - flashc 1. reading from on-chip flash may fail after a flash fuse write operation (flashc lp, up, wgpb, egpb, ssb, pgpfb, eagpf commands). after a flash fuse write operation (fl ashc lp, up, wgpb, egpb, ssb, pgpfb, eagpf commands), the following flash read access may return corrupted data. this erratum does not affect write operations to regular flash memory. fix/workaround the flash fuse write operation (flashc lp, up, wgpb, egpb, ssb, pgpfb, eagpf commands) must be issued from internal ra m. after the write operation, perform a dummy flash page write operation (flash c wp). content and location of this page is not important and filling the write buffer with a ll one (ffh) will leave the current flash content unchanged. it is then safe to read and fetch code from the flash. - dsp operations 1. hardware breakpoints may corrupt mac results hardware breakpoints on mac in structions may corrupt the dest ination register of the mac instruction. fix/workaround place breakpoints on earlier or later instructions.
652 32059l?avr32?01/2012 at32uc3b 31.2.2 rev. g - pwm 1. pwm channel interrupt enabling triggers an interrupt when enabling a pwm channel that is configured with center aligned period (calg=1), an interrupt is signalled. fix/workaround when using center aligned mode, enable the channel and read the status before channel interrupt is enabled. 2. pwn counter restarts at 0x0001 the pwm counter restarts at 0x0001 and not 0x0000 as specified. because of this the first pwm period has one more clock cycle. fix/workaround - the first period is 0x0000, 0x0001, ..., period. - consecutive periods are 0x0001, 0x0002, ..., period. 3. pwm update period to a 0 value does not work it is impossible to update a period equal to 0 by the using the pwm update register (pwm_cupd). fix/workaround do not update the pwm_cupd register with a value equal to 0. 4. spi 5. spi slave / pdca tran sfer: no tx underrun flag there is no tx underrun flag available, therefore in spi slave mode, there is no way to be informed of a character lost in transmission. fix/workaround for pdca transfer: none. 6. spi bad serial clock generation on 2nd chip_select when scbr=1, cpol=1, and ncpha=0 when multiple chip selects (cs) are in use, if one of the baudrates equal 1 while one (csrn.scbr=1) of the others do not equal 1, and csrn.cpol=1 and csrn.ncpha=0, then an additional pulse will be genera ted on sck. fix/workaround when multiple cs are in use, if one of the b audrates equals 1, the othe rs must also equal 1 if csrn.cpol=1 and csrn.ncpha=0. 7. spi glitch on rxready flag in slave mode when enabling the spi or during the first transfer in slave mode, the spi can generate a false rxready signal during enabling of the spi or during the first transfer. fix/workaround 1. set slave mode, set required cpol/cpha. 2. enable spi. 3. set the polarity cpol of the line in the opposite value of the required one. 4. set the polarity cpol to the required one. 5. read the rxholding register. transfers can now begin and rxr eady will now behave as expected.
653 32059l?avr32?01/2012 at32uc3b 8. spi disable does not work in slave mode spi disable does not work in slave mode. fix/workaround read the last received data, then perform a so ftware reset by writing a one to the software reset bit in the control register (cr.swrst). 9. spi data transfer hangs with csr0.csaat==1 and mr.modfdis==0 when csr0.csaat==1 and mode fault detection is enabled (mr.modfdis==0), the spi module will not start a data transfer. fix/workaround disable mode fault detection by writing a one to mr.modfdis. 10. disabling spi has no effect on the sr.tdre bit disabling spi has no effect on the sr.tdre bit whereas the write data command is filtered when spi is disabled. writing to tdr when spi is disabled will not clear sr.tdre. if spi is disabled during a pdca transfer, the pdca will continue to write data to tdr until its buffer is empty, and this data will be lost. fix/workaround disable the pdca, add two nops, and disable t he spi. to continue the transfer, enable the spi and pdca. 11. power manager 12. if the bod level is higher than vd dcore, the part is constantly reset if the bod level is set to a value higher than vddcore and enabled by fuses, the part will be in constant reset. fix/workaround apply an external voltage on vddcore that is higher than the bod le vel and is lower than vddcore max and disable the bod. 2. when the main clock is rcsys, ti mer_clock5 is eq ual to pba clock when the main clock is gen erated from rcsys, timer_cl ock5 is equal to pba clock and not pba clock / 128. fix/workaround none. 13. clock sources will not be stopped in static sleep mode if the difference between cpu and pbx division factor is too high if the division factor between the cpu/hsb and pbx frequencies is more than 4 when going to a sleep mode where the system rc oscillator is turned off, then high speed clock sources will not be turned off. this will result in a significantly higher power consumption during the sleep mode. fix/workaround before going to sleep modes w here the system rc oscillator is stopped, make sure that the factor between the cpu/hsb and pbx frequen cies is less than or equal to 4. 14. increased power consumption in vddio in sleep modes if the osc0 is enabled in crystal mode when entering a sleep mode where the osc0 is dis- abled, this will lead to an increased power consumption in vddio. fix/workaround disable the osc0 through the system control interface (scif) before going to any sleep mode where the osc0 is disabled, or pull down or up xin0 and xout0 with 1 mohm resistor.
654 32059l?avr32?01/2012 at32uc3b 15. ssc 16. additional delay on td output a delay from 2 to 3 system clock cy cles is added to td output when: tcmr.start = receive start, tcmr.sttdly = more than zero, rcmr.start = start on falling edge / start on rising edge / start on any edge, rfmr.fsos = none (input). fix/workaround none. 17. tf output is not correct tf output is not correct (at least emitted one serial clock cycle later than expected) when: tfmr.fsos = driven low during data transfer/ driven high during data transfer tcmr.start = receive start rfmr.fsos = none (input) rcmr.start = any on rf (edge/level) fix/workaround none. 18. frame synchro and frame synchro data are delayed by one clock cycle the frame synchro and the frame synchro data are delayed from 1 ssc_clock when: - clock is ckdiv - the start is selected on either a frame synchro edge or a level - frame synchro data is enabled - transmit clock is gated on output (through cko field) fix/workaround transmit or receive clock must not be gated (by the mean of cko field) when start condition is performed on a generated frame synchro. 19. usb 20. upcfgn.intfrq is irrelevant for isochronous pipe as a consequence, isochronous in and out to kens are sent every 1ms (full speed), or every 125us (high speed). fix/workaround for higher polling time, the software must freeze the pipe for the desired period in order to prevent any "extra" token. - adc 1. sleep mode activation needs additional a to d conversion if the adc sleep mode is activated when the ad c is idle the adc w ill not enter sleep mode before after the next ad conversion. fix/workaround activate the sleep mode in the mode regi ster and then perform an ad conversion. - pdca 1. wrong pdca behavior when using tw o pdca channels with the same pid wrong pdca behavior when using tw o pdca channels with the same pid. fix/workaround the same pid should not be assigned to more than one channel.
655 32059l?avr32?01/2012 at32uc3b 2. transfer error will stall a transm it peripheral hand shake interface if a transfer error is encountered on a channel transmitting to a peripheral, the peripheral handshake of the active channel will stall and the pdca will not do any more transfers on the affected peripheral handshake interface. fix/workaround disable and then enable the peripheral after the transfer error. 3. twi 4. the twi rxrdy flag in sr register is no t reset when a software reset is performed the twi rxrdy flag in sr register is not reset when a software reset is performed. fix/workaround after a software reset, the regi ster twi rhr must be read. 5. twi in master mode will continue to read data twi in master mode will continue to read data on the line even if the shift register and the rhr register are full. this w ill generate an overrun error. fix/workaround to prevent this, read the rhr register as soon as a new rx data is ready. 6. twi slave behaves improperly if master acknowledges the last transmitted data byte before a stop condition in i2c slave transmitter mode, if the master acknowledges the last data byte before a stop condition (what the master is not supposed to do), the following twi slave receiver mode frame may contain an inappropriate clock stretch. this clock stretch can only be stopped by resetting the twi. fix/workaround if the twi is used as a slave transmitter with a master that acknowledges the last data byte before a stop condition, it is necessary to reset the twi before entering slave receiver mode. 7. gpio 8. pa29 (twi sda) and pa30 (twi scl) gpio vih (input high voltage) is 3.6v max instead of 5v tolerant the following gpios are not 5v tolerant: pa29 and pa30. fix/workaround none. - tc 1. channel chaining skips first pulse for upper channel when chaining two channels using the block mode register, the first pulse of the clock between the channels is skipped. fix/workaround configure the lower channel with ra = 0x1 and rc = 0x2 to produce a dummy clock cycle for the upper channel. after the dummy cyc le has been generated, indicated by the sr.cpcs bit, reconfigure the ra and rc registers for the lower channel with the real values.
656 32059l?avr32?01/2012 at32uc3b - ocd 1. the auxiliary trace does not work for cpu/hsb sp eed higher than 50mhz the auxiliary trace does not work for cpu/hsb speed higher than 50mhz. fix/workaround do not use the auxiliary trace for cpu/hsb speed hig her than 50mhz. - processor and architecture 1. ldm instruction with pc in the regist er list and without ++ increments rp for ldm with pc in the register list: the instruction behaves as if the ++ field is always set, ie the pointer is alwa ys updated. this happens even if the ++ field is cleared. specifically, the increment of the pointer is done in parallel with the testing of r12. fix/workaround none. 2. rete instruction does not clear sreg[l] from interrupts the rete instruction clears sreg[l] as expected from exceptions. fix/workaround when using the stcond instruct ion, clear sreg[l] in the stacked value of sr before returning from inte rrupts with rete. 3. rets behaves incorrectly when mpu is enabled rets behaves incorrectly when mpu is enabl ed and mpu is configured so that system stack is not readable in unprivileged mode. fix/workaround make system stack readable in unprivileged mo de, or return from supervisor mode using rete instead of re ts. this requires: 1. changing the mode bits from 001 to 110 before issuing the instruction. updating the mode bits to the desired value must be done us ing a single mtsr instruction so it is done atomically. even if this step is generally describ ed as not safe in the uc technical reference manual, it is safe in th is very specific case. 2. execute the rete instruction. 4. privilege violation when using interrupts in application mode with protected system stack if the system stack is protec ted by the mpu and an interrupt occurs in application mode, an mpu dtlb exception will occur. fix/workaround make a dtlb protection (write) exception handler which permits the interrupt request to be handled in privileged mode. 5. usart 6. iso7816 info register us_ner cannot be read the ner register always returns zero. fix/workaround none. 7. iso7816 mode t1: rx impossible after any tx rx impossible after any tx. fix/workaround soft_reset on rx+ config us_mr + config_us_cr.
657 32059l?avr32?01/2012 at32uc3b 8. the rts output does not function corr ectly in hardware handshaking mode the rts signal is not generated properly when the usart receives data in hardware hand- shaking mode. when the peripheral dma receive buffer becomes full, the rts output should go high, bu t it will stay low. fix/workaround do not use the hardware handshaking mode of the usart. if it is necessary to drive the rts output high when the peripheral dma receive buffer becomes full, use the normal mode of the usart. configure the peripheral dma controller to signal an interrupt when the receive buffer is full. in the interrupt handler code, write a one to the rtsdis bit in the usart control register (cr). this will drive th e rts output high. afte r the next dma trans- fer is started and a receive buffer is availabl e, write a one to the rtsen bit in the usart cr so that rts will be driven low. 9. corruption after receiving too many bits in spi slave mode if the usart is in spi slave mode and receives too much data bits (ex: 9bitsinstead of 8 bits) by the spi master, an error occurs. after that, the next reception may be corrupted even if the frame is correct and the usart has been disabled, reset by a soft reset and re- enabled. fix/workaround none. 10. usart slave synchronous mode external cloc k must be at least 9 times lower in fre- quency than clk_usart when the usart is operating in slave synchr onous mode with an external clock, the fre- quency of the signal provided on clk must be at least 9 times lower than clk_usart. fix/workaround when the usart is operating in slave synchro nous mode with an external clock, provide a signal on clk that has a frequency at least 9 times lower than clk_usart. 11. hmatrix 12. in the pras and prbs registers, the mxpr fields are only two bits in the pras and prbs registers, the mxpr fields are only two bits wide, instead of four bits. the unused bits are undefined when reading the registers. fix/workaround mask undefined bits when reading pras and prbs. - flashc 1. reading from on-chip flash may fail after a flash fuse write operation (flashc lp, up, wgpb, egpb, ssb, pgpfb, eagpf commands). after a flash fuse write operation (fl ashc lp, up, wgpb, egpb, ssb, pgpfb, eagpf commands), the following flash read access may return corrupted data. this erratum does not affect write operations to regular flash memory. fix/workaround the flash fuse write operation (flashc lp, up, wgpb, egpb, ssb, pgpfb, eagpf commands) must be issued from internal ra m. after the write operation, perform a dummy flash page write operation (flash c wp). content and location of this page is not important and filling the write buffer with a ll one (ffh) will leave the current flash content unchanged. it is then safe to read and fetch code from the flash.
658 32059l?avr32?01/2012 at32uc3b - dsp operations 1. hardware breakpoints may corrupt mac results hardware breakpoints on mac in structions may corrupt the dest ination register of the mac instruction. fix/workaround place breakpoints on earlier or later instructions.
659 32059l?avr32?01/2012 at32uc3b 31.2.3 rev. f - pwm 1. pwm channel interrupt enabling triggers an interrupt when enabling a pwm channel that is configured with center aligned period (calg=1), an interrupt is signalled. fix/workaround when using center aligned mode, enable the channel and read the status before channel interrupt is enabled. 2. pwn counter restarts at 0x0001 the pwm counter restarts at 0x0001 and not 0x0000 as specified. because of this the first pwm period has one more clock cycle. fix/workaround - the first period is 0x0000, 0x0001, ..., period. - consecutive periods are 0x0001, 0x0002, ..., period. 3. pwm update period to a 0 value does not work it is impossible to update a period equal to 0 by the using the pwm update register (pwm_cupd). fix/workaround do not update the pwm_cupd register with a value equal to 0. 4. spi 5. spi slave / pdca tran sfer: no tx underrun flag there is no tx underrun flag available, therefore in spi slave mode, there is no way to be informed of a character lost in transmission. fix/workaround for pdca transfer: none. 6. spi bad serial clock generation on 2nd chip_select when scbr=1, cpol=1, and ncpha=0 when multiple chip selects (cs) are in use, if one of the baudrates equal 1 while one (csrn.scbr=1) of the others do not equal 1, and csrn.cpol=1 and csrn.ncpha=0, then an additional pulse will be genera ted on sck. fix/workaround when multiple cs are in use, if one of the b audrates equals 1, the othe rs must also equal 1 if csrn.cpol=1 and csrn.ncpha=0. 7. spi glitch on rxready flag in slave mode when enabling the spi or during the first transfer in slave mode, the spi can generate a false rxready signal during enabling of the spi or during the first transfer. fix/workaround 1. set slave mode, set required cpol/cpha. 2. enable spi. 3. set the polarity cpol of the line in the opposite value of the required one. 4. set the polarity cpol to the required one. 5. read the rxholding register. transfers can now begin and rxr eady will now behave as expected.
660 32059l?avr32?01/2012 at32uc3b 8. spi disable does not work in slave mode spi disable does not work in slave mode. fix/workaround read the last received data, then perform a so ftware reset by writing a one to the software reset bit in the control register (cr.swrst). 9. spi data transfer hangs with csr0.csaat==1 and mr.modfdis==0 when csr0.csaat==1 and mode fault detection is enabled (mr.modfdis==0), the spi module will not start a data transfer. fix/workaround disable mode fault detection by writing a one to mr.modfdis. 10. disabling spi has no effect on the sr.tdre bit disabling spi has no effect on the sr.tdre bit whereas the write data command is filtered when spi is disabled. writing to tdr when spi is disabled will not clear sr.tdre. if spi is disabled during a pdca transfer, the pdca will continue to write data to tdr until its buffer is empty, and this data will be lost. fix/workaround disable the pdca, add two nops, and disable t he spi. to continue the transfer, enable the spi and pdca. 11. power manager 12. if the bod level is higher than vd dcore, the part is constantly reset if the bod level is set to a value higher than vddcore and enabled by fuses, the part will be in constant reset. fix/workaround apply an external voltage on vddcore that is higher than the bod le vel and is lower than vddcore max and disable the bod. 3. when the main clock is rcsys, ti mer_clock5 is eq ual to pba clock when the main clock is gen erated from rcsys, timer_cl ock5 is equal to pba clock and not pba clock / 128. fix/workaround none. 13. clock sources will not be stopped in static sleep mode if the difference between cpu and pbx division factor is too high if the division factor between the cpu/hsb and pbx frequencies is more than 4 when going to a sleep mode where the system rc oscillator is turned off, then high speed clock sources will not be turned off. this will result in a significantly higher power consumption during the sleep mode. fix/workaround before going to sleep modes w here the system rc oscillator is stopped, make sure that the factor between the cpu/hsb and pbx frequen cies is less than or equal to 4. 14. increased power consumption in vddio in sleep modes if the osc0 is enabled in crystal mode when entering a sleep mode where the osc0 is dis- abled, this will lead to an increased power consumption in vddio. fix/workaround disable the osc0 through the system control interface (scif) before going to any sleep mode where the osc0 is disabled, or pull down or up xin0 and xout0 with 1 mohm resistor.
661 32059l?avr32?01/2012 at32uc3b 15. ssc 16. additional delay on td output a delay from 2 to 3 system clock cy cles is added to td output when: tcmr.start = receive start, tcmr.sttdly = more than zero, rcmr.start = start on falling edge / start on rising edge / start on any edge, rfmr.fsos = none (input). fix/workaround none. 17. tf output is not correct tf output is not correct (at least emitted one serial clock cycle later than expected) when: tfmr.fsos = driven low during data transfer/ driven high during data transfer tcmr.start = receive start rfmr.fsos = none (input) rcmr.start = any on rf (edge/level) fix/workaround none. 18. frame synchro and frame synchro data are delayed by one clock cycle the frame synchro and the frame synchro data are delayed from 1 ssc_clock when: - clock is ckdiv - the start is selected on either a frame synchro edge or a level - frame synchro data is enabled - transmit clock is gated on output (through cko field) fix/workaround transmit or receive clock must not be gated (by the mean of cko field) when start condition is performed on a generated frame synchro. 19. usb 20. upcfgn.intfrq is irrelevant for isochronous pipe as a consequence, isochronous in and out to kens are sent every 1ms (full speed), or every 125us (high speed). fix/workaround for higher polling time, the software must freeze the pipe for the desired period in order to prevent any "extra" token. - adc 1. sleep mode activation needs additional a to d conversion if the adc sleep mode is activated when the ad c is idle the adc w ill not enter sleep mode before after the next ad conversion. fix/workaround activate the sleep mode in the mode regi ster and then perform an ad conversion. - pdca 1. wrong pdca behavior when using tw o pdca channels with the same pid wrong pdca behavior when using tw o pdca channels with the same pid. fix/workaround the same pid should not be assigned to more than one channel.
662 32059l?avr32?01/2012 at32uc3b 2. transfer error will stall a transm it peripheral hand shake interface if a transfer error is encountered on a channel transmitting to a peripheral, the peripheral handshake of the active channel will stall and the pdca will not do any more transfers on the affected peripheral handshake interface. fix/workaround disable and then enable the peripheral after the transfer error. 3. twi 4. the twi rxrdy flag in sr register is no t reset when a software reset is performed the twi rxrdy flag in sr register is not reset when a software reset is performed. fix/workaround after a software reset, the regi ster twi rhr must be read. 5. twi in master mode will continue to read data twi in master mode will continue to read data on the line even if the shift register and the rhr register are full. this w ill generate an overrun error. fix/workaround to prevent this, read the rhr register as soon as a new rx data is ready. 6. twi slave behaves improperly if master acknowledges the last transmitted data byte before a stop condition in i2c slave transmitter mode, if the master acknowledges the last data byte before a stop condition (what the master is not supposed to do), the following twi slave receiver mode frame may contain an inappropriate clock stretch. this clock stretch can only be stopped by resetting the twi. fix/workaround if the twi is used as a slave transmitter with a master that acknowledges the last data byte before a stop condition, it is necessary to reset the twi before entering slave receiver mode. 7. gpio 8. pa29 (twi sda) and pa30 (twi scl) gpio vih (input high voltage) is 3.6v max instead of 5v tolerant the following gpios are not 5v tolerant: pa29 and pa30. fix/workaround none. 9. some gpio vih (input high voltage) are 3.6v max instead of 5v tolerant only 11 gpios remain 5v tolerant (vihma x=5v):pb01, pb02, pb03, pb10, pb19, pb20, pb21, pb22, pb23, pb27, pb28. fix/workaround none. 10. tc 11. channel chaining skips first pulse for upper channel when chaining two channels using the block mode register, the first pulse of the clock between the channels is skipped. fix/workaround configure the lower channel with ra = 0x1 and rc = 0x2 to produce a dummy clock cycle for the upper channel. after the dummy cyc le has been generated, indicated by the
663 32059l?avr32?01/2012 at32uc3b sr.cpcs bit, reconfigure the ra and rc registers for the lower channel with the real values. - ocd 1. the auxiliary trace does not work for cpu/hsb sp eed higher than 50mhz the auxiliary trace does not work for cpu/hsb speed higher than 50mhz. fix/workaround do not use the auxiliary trace for cpu/hsb speed hig her than 50mhz. - processor and architecture 1. ldm instruction with pc in the regist er list and without ++ increments rp for ldm with pc in the register list: the instruction behaves as if the ++ field is always set, ie the pointer is alwa ys updated. this happens even if the ++ field is cleared. specifically, the increment of the pointer is done in parallel with the testing of r12. fix/workaround none. 2. rete instruction does not clear sreg[l] from interrupts the rete instruction clears sreg[l] as expected from exceptions. fix/workaround when using the stcond instruct ion, clear sreg[l] in the stacked value of sr before returning from inte rrupts with rete. 3. rets behaves incorrectly when mpu is enabled rets behaves incorrectly when mpu is enabl ed and mpu is configured so that system stack is not readable in unprivileged mode. fix/workaround make system stack readable in unprivileged mo de, or return from supervisor mode using rete instead of re ts. this requires: 1. changing the mode bits from 001 to 110 before issuing the instruction. updating the mode bits to the desired value must be done us ing a single mtsr instruction so it is done atomically. even if this step is generally describ ed as not safe in the uc technical reference manual, it is safe in th is very specific case. 2. execute the rete instruction. 4. privilege violation when using interrupts in application mode with protected system stack if the system stack is protec ted by the mpu and an interrupt occurs in application mode, an mpu dtlb exception will occur. fix/workaround make a dtlb protection (write) exception handler which permits the interrupt request to be handled in privileged mode. 5. usart 6. iso7816 info register us_ner cannot be read the ner register always returns zero. fix/workaround none.
664 32059l?avr32?01/2012 at32uc3b 7. iso7816 mode t1: rx impossible after any tx rx impossible after any tx. fix/workaround soft_reset on rx+ config us_mr + config_us_cr. 8. the rts output does not function corr ectly in hardware handshaking mode the rts signal is not generated properly when the usart receives data in hardware hand- shaking mode. when the peripheral dma receive buffer becomes full, the rts output should go high, bu t it will stay low. fix/workaround do not use the hardware handshaking mode of the usart. if it is necessary to drive the rts output high when the peripheral dma receive buffer becomes full, use the normal mode of the usart. configure the peripheral dma controller to signal an interrupt when the receive buffer is full. in the interrupt handler code, write a one to the rtsdis bit in the usart control register (cr). this will drive th e rts output high. afte r the next dma trans- fer is started and a receive buffer is availabl e, write a one to the rtsen bit in the usart cr so that rts will be driven low. 9. corruption after receiving too many bits in spi slave mode if the usart is in spi slave mode and receives too much data bits (ex: 9bitsinstead of 8 bits) by the spi master, an error occurs. after that, the next reception may be corrupted even if the frame is correct and the usart has been disabled, reset by a soft reset and re- enabled. fix/workaround none. 10. usart slave synchronous mode external cloc k must be at least 9 times lower in fre- quency than clk_usart when the usart is operating in slave synchr onous mode with an external clock, the fre- quency of the signal provided on clk must be at least 9 times lower than clk_usart. fix/workaround when the usart is operating in slave synchro nous mode with an external clock, provide a signal on clk that has a frequency at least 9 times lower than clk_usart. 11. hmatrix 12. in the pras and prbs registers, the mxpr fields are only two bits in the pras and prbs registers, the mxpr fields are only two bits wide, instead of four bits. the unused bits are undefined when reading the registers. fix/workaround mask undefined bits when reading pras and prbs. - flashc 1. reading from on-chip flash may fail after a flash fuse write operation (flashc lp, up, wgpb, egpb, ssb, pgpfb, eagpf commands). after a flash fuse write operation (fl ashc lp, up, wgpb, egpb, ssb, pgpfb, eagpf commands), the following flash read access may return corrupted data. this erratum does not affect write operations to regular flash memory. fix/workaround the flash fuse write operation (flashc lp, up, wgpb, egpb, ssb, pgpfb, eagpf commands) must be issued from internal ra m. after the write operation, perform a dummy flash page write operation (flash c wp). content and location of this page is not important
665 32059l?avr32?01/2012 at32uc3b and filling the write buffer with a ll one (ffh) will leave the current flash content unchanged. it is then safe to read and fetch code from the flash. - dsp operations 1. hardware breakpoints may corrupt mac results hardware breakpoints on mac in structions may corrupt the dest ination register of the mac instruction. fix/workaround place breakpoints on earlier or later instructions.
666 32059l?avr32?01/2012 at32uc3b 31.2.4 rev. b - pwm 1. pwm channel interrupt enabling triggers an interrupt when enabling a pwm channel that is configured with center aligned period (calg=1), an interrupt is signalled. fix/workaround when using center aligned mode, enable the channel and read the status before channel interrupt is enabled. 2. pwn counter restarts at 0x0001 the pwm counter restarts at 0x0001 and not 0x0000 as specified. because of this the first pwm period has one more clock cycle. fix/workaround - the first period is 0x0000, 0x0001, ..., period. - consecutive periods are 0x0001, 0x0002, ..., period. 3. pwm update period to a 0 value does not work it is impossible to update a period equal to 0 by the using the pwm update register (pwm_cupd). fix/workaround do not update the pwm_cupd register with a value equal to 0. 4. pwm channel status may be wrong if disabled before a period has elapsed before a pwm period has elapsed, the read channel status may be wrong. the chidx-bit for a pwm channel in the pwm enable register will read '1' fo r one full pwm period even if the channel was disabled before the period elapsed. it will then read '0' as expected. fix/workaround reading the pwm channel status of a disabled channel is only correct after a pwm period has elapsed. 5. the following alternate c functions pwm[4] on pa16 and pwm[6] on pa31 are not available on rev b the following alternate c functions pwm[4] on pa16 and pwm[6] on pa31 are not available on rev b. fix/workaround do not use these pwm alternate functions on these pins. 6. spi 7. spi slave / pdca tran sfer: no tx underrun flag there is no tx underrun flag available, therefore in spi slave mode, there is no way to be informed of a character lost in transmission. fix/workaround for pdca transfer: none.
667 32059l?avr32?01/2012 at32uc3b 8. spi bad serial clock generation on 2nd chip_select when scbr=1, cpol=1, and ncpha=0 when multiple chip selects (cs) are in use, if one of the baudrates equal 1 while one (csrn.scbr=1) of the others do not equal 1, and csrn.cpol=1 and csrn.ncpha=0, then an additional pulse will be genera ted on sck. fix/workaround when multiple cs are in use, if one of the b audrates equals 1, the othe rs must also equal 1 if csrn.cpol=1 and csrn.ncpha=0. 9. spi glitch on rxready flag in slave mode when enabling the spi or during the first transfer in slave mode, the spi can generate a false rxready signal during enabling of the spi or during the first transfer. fix/workaround 1. set slave mode, set required cpol/cpha. 2. enable spi. 3. set the polarity cpol of the line in the opposite value of the required one. 4. set the polarity cpol to the required one. 5. read the rxholding register. transfers can now begin and rxr eady will now behave as expected. 10. spi csnaat bit 2 in register csr0...csr3 is not available spi csnaat bit 2 in register csr0...csr3 is not available. fix/workaround do not use this bit. 11. spi disable does not work in slave mode spi disable does not work in slave mode. fix/workaround read the last received data, then perform a so ftware reset by writing a one to the software reset bit in the control register (cr.swrst). - power manager 1. pll lock control does not work pll lock control does not work. fix/workaround in pll control register, the bit 7 should be set in order to prevent unexpected behavior. 2. wrong reset causes when bod is activated setting the bod enable fuse will cause the rese t cause register to list bod reset as the reset source even though the part was reset by another source. fix/workaround do not set the bod enable fuse , but activate the bod as soon as your program starts. 3. system timer mask (bit 16) of the pm cpumask register is not available system timer mask (bit 16) of the pm cpumask register is not available. fix/workaround do not use this bit.
668 32059l?avr32?01/2012 at32uc3b - ssc 1. ssc does not trigger rf when data is low the ssc cannot transmit or receive data wh en cks = ckdiv and cko = none, in tcmr or rcmr respectively. fix/workaround set cko to a value that is not "none" and bypa ss the output of the tk/rk pin with the gpio. - usb 1. usb no end of host reset signaled upon disconnection in host mode, in case of an unexpected devic e disconnection whereas a usb reset is being sent by the usb controller, the uhcon.reset bit may not been cleared by th e hardware at the end of the reset. fix/workaround a software workaround consists in testing (by polling or interrupt ) the disconnection (uhint.ddisci == 1) while waiting for the end of reset (uhcon.reset == 0) to avoid being stuck. 2. usbfsm and uhaddr1/2/3 re gisters are no t available do not use usbfsm register. fix/workaround do not use usbfsm register and use hc on[6:0] field instead for all the pipes. - cycle counter 1. cpu cycle counter does not reset the count system register on compare match. the device revision b does not reset the co unt system register on compare match. in this revision, the count register is clocke d by the cpu clock, so when the cpu clock stops, so does incrementing of count . fix/workaround none. - adc 1. adc possible miss on drdy when disabling a channel the adc does not work properly when more than one channel is enabled. fix/workaround do not use the adc with more than one channel enabled at a time. 2. adc ovre flag sometimes not reset on status register read the ovre flag does not clear properly if re ad simultaneously to an end of conversion. fix/workaround none. 3. sleep mode activation needs additional a to d conversion if the adc sleep mode is activated when the ad c is idle the adc w ill not enter sleep mode before after the next ad conversion. fix/workaround activate the sleep mode in the mode regi ster and then perform an ad conversion.
669 32059l?avr32?01/2012 at32uc3b - usart 1. usart manchester encoder not working manchester encoding/decoding is not working. fix/workaround do not use manchester encoding. 2. usart rxbreak problem when no timeguard in asynchronous mode the rxbreak flag is not correctly handled when the timeguard is 0 and the break character is located just after the stop bit. fix/workaround if the nbstop is 1, timeguar d should be different from 0. 3. usart handshaking: 2 characters sent / cts rises when tx if cts switches from 0 to 1 during the tx of a character, if the holdi ng register is not empty, the txholding is also transmitted. fix/workaround none. 4. usart pdc and timeguard not supported in manchester manchester encoding/decoding is not working. fix/workaround do not use manchester encoding. 5. usart spi mode is non functional on this revision usart spi mode is non func tional on this revision. fix/workaround do not use the usart spi mode. - hmatrix 1. hmatrix fixed priority arbitration does not work fixed priority arbitration does not work. fix/workaround use round-robin arbitration instead. - clock characteristic 1. pba max frequency the peripheral bus a (pba) max frequency is 30mhz instead of 60mhz. fix/workaround do not set the pba maximum fr equency higher than 30mhz. - flashc 1. the address of flash general purpose fuse register low (fgpfrlo) is 0xfffe140c on revb instead of 0xfffe1410 the address of flash general purpose fuse register low (fgp frlo) is 0xfffe140c on revb instead of 0xfffe1410. fix/workaround none.
670 32059l?avr32?01/2012 at32uc3b 2. the command quick page read user page(qprup) is not functional the command quick page read user page(qprup) is not functional. fix/workaround none. 3. pagen semantic field for program gp fuse byte is writedata[7:0], byteaddress[1:0] on revision b instead of writedata[7:0], byteaddress[2:0] pagen semantic field for program gp fuse by te is writedata[7:0], byteaddress[1:0] on revision b instead of writed ata[7:0], byteaddress[2:0]. fix/workaround none. 4. reading from on-chip flash may fail after a flash fuse write operation (flashc lp, up, wgpb, egpb, ssb, pgpfb, eagpf commands). after a flash fuse write operation (fl ashc lp, up, wgpb, egpb, ssb, pgpfb, eagpf commands), the following flash read access may return corrupted data. this erratum does not affect write operations to regular flash memory. fix/workaround the flash fuse write operation (flashc lp, up, wgpb, egpb, ssb, pgpfb, eagpf commands) must be issued from internal ra m. after the write operation, perform a dummy flash page write operation (flash c wp). content and location of this page is not important and filling the write buffer with a ll one (ffh) will leave the current flash content unchanged. it is then safe to read and fetch code from the flash. 5. - rtc 1. writes to control (ctrl), top (top) and va lue (val) in the rtc are discarded if the rtc peripheral bus clock (pba) is divided by a factor of four or more relative to the hsb clock writes to control (ctrl), top (top) and val ue (val) in the rtc are discarded if the rtc peripheral bus clock (pba) is di vided by a factor of four or more relative to the hsb clock. fix/workaround do not write to the rt c registers using the peripheral bus clock (pba) divided by a factor of four or more relative to the hsb clock. 2. the rtc clken bit (bit number 16) of ctrl register is not available the rtc clken bit (bit number 16) of ctrl register is not available. fix/workaround do not use the clken bit of the rtc on rev b.
671 32059l?avr32?01/2012 at32uc3b - ocd 1. stalled memory access instruction writeback fails if followed by a hw breakpoint consider the following assembly code sequence: a b if a hardware breakpoint is placed on instructio n b, and instruction a is a memory access instruction, register file updates from instruction a can be discarded. fix/workaround do not place hardware breakpoints, use software breakpoints instead. alternatively, place a hardware breakpoint on the instruction before the memory access instruction and then sin- gle step over the memory access instruction. - processor and architecture 1. local bus to fast gpio not available on silicon rev b local bus is only available for silicon reve and later. fix/workaround do not use if silicon revision older than f. 2. memory protection unit (mpu) is non functional memory protection unit (mpu) is non functional. fix/workaround do not use the mpu. 3. bus error should be masked in debug mode if a bus error occurs during debug mode, the processor will not respond to debug com- mands through the dinst register. fix/workaround a reset of the device will make the cp u respond to debug commands again. 4. read modify write (rmw) instructions on data outside the internal ram does not work read modify write (rmw) instructions on da ta outside the internal ram does not work. fix/workaround do not perform rmw instructions on data outside the internal ram. 5. need two nops instruction after instructions masking interrupts the instructions following in the pipeline the instruction masking the interrupt through sr may behave abnormally. fix/workaround place two nops instructions after each ssrf or mtsr instruction sett ing ixm or gm in sr 6. clock connection table on rev b here is the table of rev b
672 32059l?avr32?01/2012 at32uc3b figure 31-1. timer/counter clock connections on revb 7. spurious interrupt may corrupt core sr mode to exception if the rules listed in the c hapter `masking interrupt requests in peripheral modules' of the avr32uc technical reference manual are not followed, a spurious interrupt may occur. an interrupt context will be pushed onto the stac k while the core sr mode will indicate an exception. a rete instruction would then corrupt the stack. fix/workaround follow the rules of the avr32uc technical reference manual. to increase software robustness, if an exception mode is detec ted at the beginning of an interrupt handler, change the stack interrupt context to an e xception context and issu e a rete instruction. 8. cpu cannot operate on a divided slow clock (internal rc oscillator) cpu cannot operate on a divided slow clock (i nternal rc oscillator). fix/workaround do not run the cpu on a divided slow clock. 9. ldm instruction with pc in the regist er list and without ++ increments rp for ldm with pc in the register list: the instruction behaves as if the ++ field is always set, i.e. the pointer is always updated. this happens ev en if the ++ field is cleared. specifically, the increment of the pointer is done in parallel with the testing of r12. fix/workaround none. 10. rete instruction does not clear sreg[l] from interrupts the rete instruction clears sreg[l] as expected from exceptions. fix/workaround when using the stcond instruct ion, clear sreg[l] in the stacked value of sr before returning from inte rrupts with rete. 11. exceptions when system stack is protected by mpu rets behaves incorrectly when mpu is enabl ed and mpu is configured so that system stack is not readable in unprivileged mode. fix/workaround workaround 1: make system stack readable in unprivileged mode, or workaround 2: return from supervisor mode using rete instead of rets. this requires: 1. changing the mode bits from 001b to 110b before issuing the instruction. updating the mode bits to the desired value mu st be done using a single mtsr instruction so source name connection internal timer_clock1 32khz oscillator timer_clock2 pba clock / 4 timer_clock3 pba clock / 8 timer_clock4 pba clock / 16 timer_clock5 pba clock / 32 external xc0 xc1 xc2
673 32059l?avr32?01/2012 at32uc3b it is done atomically. even if th is step is described in general as not safe in the uc technical reference guide, it is safe in this very specific case. 2. execute the rete instruction.
674 32059l?avr32?01/2012 at32uc3b 32. datasheet revision history please note that the referring page numbers in th is section are referred to this document. the referring revision in this section ar e referring to the document revision. 32.1 rev. l? 01/2012 32.2 rev. k? 02/2011 32.3 rev. j? 12/2010 32.4 rev. i ? 06/2010 32.5 rev. h ? 10/2009 1. updated mechanical characteristics section. 1. updated usb section. 2. updated configuration summary section. 3. updated electrical characteristics section. 4. updated errata section. 1. updated usb section. 2. updated usart section. 3. updated twi section. 4. updated pwm section. 5. updated electrical characteristics section. 1. updated spi section. 2 updated electrical characteristics section. 1. update datasheet architecture. 2 add at32uc3b0512 and at32uc3b1512 devices description.
675 32059l?avr32?01/2012 at32uc3b 32.6 rev. g ? 06/2009 32.7 rev. f ? 04/2008 32.8 rev. e ? 12/2007 32.9 rev. d ? 11/2007 32.10 rev. c ? 10/2007 32.11 rev. b ? 07/2007 1. open drain mode removed from gpio section. 2 updated errata section. 1. updated errata section. 1. updated memory protection section. 1. updated processor architecture section. 2. updated electrical characteristics section. 1. updated features sections. 2. updated block diagram with local bus figure 3. add schematic for hmatrix master/slave connection. 4. updated features sections with local bus. 5. added spi feature to usart section. 6. updated usbb section. 7. updated adc trigger selection in adc section. 8. updated jtag and boundary scan se ction with programming procedure. 9. add description for silicon revision d 1. updated registered trademarks 2. updated address page.
676 32059l?avr32?01/2012 at32uc3b 32.12 rev. a ? 05/2007 1. initial revision.
677 32059l?avr32?01/2012 at32uc3b table of contents 1 description ............ .............. .............. ............... .............. .............. ............ 3 2 overview ................ .............. .............. ............... .............. .............. ............ 4 2.1 blockdiagram .................. ...................................................................................4 3 configuration summary ........ .............. .............. .............. .............. .......... 5 4 package and pinout ............ .............. ............... .............. .............. ............ 6 4.1 package .............................................................................................................6 4.2 peripheral multiplexing on i/o lines . ..................................................................7 4.3 high drive current gpio .................................................................................10 5 signals description ............ .............. ............... .............. .............. .......... 10 5.1 jtag pins ........................................................................................................13 5.2 reset_n pin ..................................................................................................14 5.3 twi pins ..........................................................................................................14 5.4 gpio pins ........................................................................................................14 5.5 high drive pins .................................................................................................14 5.6 power considerations .....................................................................................14 6 processor and architecture .... ................ ................. ................ ............. 17 6.1 features ..........................................................................................................17 6.2 avr32 architecture ..... ....................................................................................17 6.3 the avr32uc cpu ........................................................................................18 6.4 programming model ........................................................................................22 6.5 exceptions and interrupts ................................................................................26 6.6 module configuration ......................................................................................30 7 memories ............... .............. .............. ............... .............. .............. .......... 31 7.1 embedded memories ......................................................................................31 7.2 physical memory map .....................................................................................31 7.3 peripheral address map ..................................................................................32 7.4 cpu local bus mapping .................................................................................33 8 boot sequence ........... ................ ................. ................ ................. .......... 34 8.1 starting of clocks .............................................................................................34 8.2 fetching of initial instru ctions ..........................................................................34 9 power manager (pm) .. ................ ................. ................ ................. .......... 35 9.1 features ..........................................................................................................35
678 32059l?avr32?01/2012 at32uc3b 9.2 description .......................................................................................................35 9.3 block diagram .................................................................................................36 9.4 product dependencies ....................................................................................37 9.5 functional description .....................................................................................37 9.6 user interface ..................................................................................................49 10 real time counter (rtc) ... .............. ............... .............. .............. .......... 72 10.1 features ..........................................................................................................72 10.2 overview ..........................................................................................................72 10.3 block diagram .................................................................................................72 10.4 product dependencies ....................................................................................72 10.5 functional description .....................................................................................73 10.6 user interface ..................................................................................................75 11 watchdog timer (wdt) ........... ................ ................. ................ ............. 84 11.1 features ..........................................................................................................84 11.2 overview ..........................................................................................................84 11.3 block diagram .................................................................................................84 11.4 product dependencies ....................................................................................84 11.5 functional description .....................................................................................85 11.6 user interface ..................................................................................................85 12 interrupt controller (intc) . .............. ............... .............. .............. .......... 88 12.1 features ..........................................................................................................88 12.2 overview ..........................................................................................................88 12.3 block diagram .................................................................................................88 12.4 product dependencies ....................................................................................89 12.5 functional description .....................................................................................89 12.6 user interface ..................................................................................................92 12.7 interrupt request signal map ..........................................................................96 13 external interrupt controll er (eic) ............ ................ ................. .......... 98 13.1 features ..........................................................................................................98 13.2 overview ..........................................................................................................98 13.3 block diagram .................................................................................................99 13.4 i/o lines description .......................................................................................99 13.5 product dependencies ....................................................................................99 13.6 functional description ...................................................................................100 13.7 user interface ................................................................................................104
679 32059l?avr32?01/2012 at32uc3b 14 flash controller (flashc) .............. ............... .............. .............. ........ 120 14.1 features ........................................................................................................120 14.2 overview ........................................................................................................120 14.3 product dependencies ...................................................................................120 14.4 functional description ....................................................................................121 14.5 flash commands ...........................................................................................123 14.6 general-purpose fuse bits .............................................................................125 14.7 security bit .....................................................................................................127 14.8 user interface ................................................................................................128 14.9 fuses settings ...............................................................................................136 14.10 bootloader configuration ...............................................................................137 14.11 serial number ................................................................................................137 14.12 module configuration .....................................................................................137 15 hsb bus matrix (hmatrix) .. ................ ................. ................ ............. 138 15.1 features ........................................................................................................138 15.2 overview ........................................................................................................138 15.3 product dependencies ..................................................................................138 15.4 functional description ...................................................................................138 15.5 user interface ................................................................................................142 15.6 bus matrix connections .................................................................................150 16 peripheral dma controller (pdca) ............. .............. .............. ........... 152 16.1 features ........................................................................................................152 16.2 overview ........................................................................................................152 16.3 block diagram ...............................................................................................153 16.4 product dependencies ..................................................................................153 16.5 functional description ...................................................................................154 16.6 user interface ................................................................................................157 16.7 module configuration ....................................................................................170 17 general-purpose input/out put controller (gpio) .. ................ ........... 171 17.1 features ........................................................................................................171 17.2 overview ........................................................................................................171 17.3 block diagram ...............................................................................................171 17.4 product dependencies ..................................................................................171 17.5 functional description ...................................................................................172 17.6 user interface ................................................................................................176
680 32059l?avr32?01/2012 at32uc3b 17.7 programming examples ................................................................................191 17.8 module configuration ....................................................................................193 18 serial peripheral interface (spi) ......... .............. .............. ............ ........ 194 18.1 features ........................................................................................................194 18.2 overview ........................................................................................................194 18.3 block diagram ...............................................................................................195 18.4 application block diagram .................. ...........................................................195 18.5 signal description .........................................................................................196 18.6 product dependencies ..................................................................................196 18.7 functional description ...................................................................................196 18.8 user interface ................................................................................................206 19 two-wire interface (t wi) ................ .............. .............. .............. ........... 218 19.1 features ........................................................................................................218 19.2 overview ........................................................................................................218 19.3 list of abbreviations ......................................................................................219 19.4 block diagram ...............................................................................................219 19.5 application block diagram .................. ...........................................................220 19.6 i/o lines description .....................................................................................220 19.7 product dependencies ..................................................................................220 19.8 functional description ...................................................................................221 19.9 modes of operation .......................................................................................221 19.10 master mode ..................................................................................................222 19.11 using the peripheral dma controller ............................................................226 19.12 multi-master mode .........................................................................................234 19.13 slave mode ....................................................................................................237 19.14 user interface ................................................................................................245 20 synchronous serial controller (ssc) .... ................. ................ ........... 259 20.1 features ........................................................................................................259 20.2 overview ........................................................................................................259 20.3 block diagram ...............................................................................................260 20.4 application block diagram .................. ...........................................................260 20.5 i/o lines description .....................................................................................261 20.6 product dependencies ..................................................................................261 20.7 functional description ...................................................................................261 20.8 ssc application examples ............................................................................273
681 32059l?avr32?01/2012 at32uc3b 20.9 user interface ................................................................................................275 21 universal synchronous asynchr onous receiver transmitter (usart) 297 21.1 features ........................................................................................................297 21.2 overview ........................................................................................................297 21.3 block diagram ...............................................................................................298 21.4 i/o lines description ....................................................................................299 21.5 product dependencies ..................................................................................299 21.6 functional description ...................................................................................300 21.7 user interface ................................................................................................327 21.8 module configuration ....................................................................................351 22 usb interface (usbb) ....... .............. .............. .............. .............. ........... 352 22.1 features ........................................................................................................352 22.2 overview ........................................................................................................352 22.3 block diagram ...............................................................................................353 22.4 application block diagram .................. ...........................................................355 22.5 i/o lines description .....................................................................................357 22.6 product dependencies ..................................................................................358 22.7 functional description ...................................................................................359 22.8 user interface ................................................................................................393 23 timer/counter (tc) ........... .............. .............. .............. .............. ........... 472 23.1 features ........................................................................................................472 23.2 overview ........................................................................................................472 23.3 block diagram ...............................................................................................473 23.4 i/o lines description .....................................................................................473 23.5 product dependencies ..................................................................................473 23.6 functional description ...................................................................................474 23.7 user interface ................................................................................................489 23.8 module configuration ....................................................................................512 24 pulse width modulation c ontroller (pwm) . .............. .............. ........... 513 24.1 features ........................................................................................................513 24.2 description .....................................................................................................513 24.3 block diagram ...............................................................................................514 24.4 i/o lines description .....................................................................................514 24.5 product dependencies ..................................................................................515
682 32059l?avr32?01/2012 at32uc3b 24.6 functional description ...................................................................................516 24.7 user interface ................................................................................................524 25 analog-to-digital converte r (adc) ....... ................. ................ ............. 539 25.1 features ........................................................................................................539 25.2 overview ........................................................................................................539 25.3 block diagram ...............................................................................................540 25.4 i/o lines description .....................................................................................540 25.5 product dependencies ..................................................................................540 25.6 functional description ...................................................................................541 25.7 user interface ................................................................................................546 25.8 module configuration ....................................................................................559 26 audio bitstream dac (abdac) .............. ................. ................ ........... 560 26.1 features ........................................................................................................560 26.2 overview ........................................................................................................560 26.3 block diagram ...............................................................................................561 26.4 i/o lines description .....................................................................................561 26.5 product dependencies ..................................................................................561 26.6 functional description ...................................................................................562 26.7 user interface ................................................................................................565 27 programming and debugging .. ................. ................ .............. ........... 573 27.1 overview ........................................................................................................573 27.2 service access bus .......................................................................................573 27.3 on-chip debug (ocd) ..................................................................................575 27.4 jtag and boundary-scan (jtag) .................................................................582 27.5 jtag instruction summary ................ ...........................................................590 27.6 jtag data registers .....................................................................................605 27.7 sab address map ........... ................. ................ ............. ............ ............. ........606 28 electrical characteristics ... .............. ............... .............. .............. ........ 607 28.1 absolute maximum rating s* .........................................................................607 28.2 dc characteristics .........................................................................................608 28.3 regulator characteristics ..............................................................................610 28.4 analog characteristics ...................................................................................610 28.5 power consumption ......................................................................................614 28.6 system clock characteristics ........................................................................617 28.7 oscillator characteristics ...............................................................................618
683 32059l?avr32?01/2012 at32uc3b 28.8 adc characteristics ......................................................................................620 28.9 usb transceiver characteristics ...................................................................622 28.10 jtag characteristics .....................................................................................623 28.11 spi characteristics ........................................................................................624 28.12 flash memory characteristics .......................................................................626 29 mechanical characteristics ... ................ ................. ................ ............. 627 29.1 thermal considerations ................................................................................627 29.2 package drawings .........................................................................................628 29.3 soldering profile ............................................................................................632 30 ordering information .......... .............. ............... .............. .............. ........ 633 31 errata ........... ................ ................ ................. ................ .............. ........... 634 31.1 at32uc3b0512, at32uc3b1512 ........... .....................................................634 31.2 at32uc3b0256, at32uc3b0128, at32uc3b064, at32uc3b1256, at32uc3b1128, at32uc3b164 646 32 datasheet revision history .. ................ ................. ................ ............. 674 32.1 rev. l? 01/2012 ............................................................................................674 32.2 rev. k? 02/2011 ............................................................................................674 32.3 rev. j? 12/2010 ............................................................................................674 32.4 rev. i ? 06/2010 ............................................................................................674 32.5 rev. h ? 10/2009 ...........................................................................................674 32.6 rev. g ? 06/2009 ..........................................................................................675 32.7 rev. f ? 04/2008 ...........................................................................................675 32.8 rev. e ? 12/2007 ...........................................................................................675 32.9 rev. d ? 11/2007 ...........................................................................................675 32.10 rev. c ? 10/2007 ...........................................................................................675 32.11 rev. b ? 07/2007 ...........................................................................................675 32.12 rev. a ? 05/2007 ...........................................................................................676
32059l?avr32?01/2012 atmel corporation 2325 orchard parkway san jose, ca 95131 usa tel : (+1)(408) 441-0311 fax : (+1)(408) 487-2600 www.atmel.com atmel asia limited unit 1-5 & 16, 19/f bea tower, millennium city 5 418 kwun tong road kwun tong, kowloon hong kong tel : (+852) 2245-6100 fax : (+852) 2722-1369 atmel munich gmbh business campus parkring 4 d-85748 garching b. munich germany tel : (+49) 89-31970-0 fax : (+49) 89-3194621 atmel japan 16f, shin osaki kangyo bldg. 1-6-4 osaka shinagawa-ku tokyo 104-0032 japan tel : (+81) 3-6417-0300 fax : (+81) 3-6417-0370 ? 2012 atmel corporation. all rights reserved. atmel ? , atmel logo and combinations thereof avr ? , qtouch ? , adjacent key suppression ? , aks ? , and others are registered trade- marks or trademarks of atmel corporati on or its subsidiaries. other terms a nd product names may be trademarks of others. disclaimer: the information in this document is provided in connection with atmel products. no license, expr ess or implied, by estoppel or otherwise, to any intellectual property right is gran ted by this document or in connection with the sale of atmel products. except as set forth in the atmel terms and conditions of sales located on the atmel website, atmel assumes no liability whatsoever and disclaims any express, implied or statutory warranty relating to its produc ts including, but not limited to, the implied warranty of merchantability, fitness for a particular purp ose, or non-infringement. in no event shall atmel be liable for any direct, indirect, consequential, punitive, specia l or incidental damages (including, with out limitation, damages for loss and prof- its, business interruption, or loss of information) arising out of the use or inability to use this document, even if atmel has been advised of the possibility of such damages. atmel makes no representations or warranties with respect to the accuracy or com- pleteness of the contents of this document and reserves the ri ght to make changes to specifications and product descriptions at any time without notice. atmel does not make any commitment to update the information c ontained herein. unless specifica lly provided otherwise, atmel pr oducts are not suit- able for, and shall not be used in, automotive applications. at mel products are not intended, authorized, or warranted for use as components in applica- tions intended to support or sustain life.


▲Up To Search▲   

 
Price & Availability of TS80C32X2-LIB

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X